chore(plugin-form-builder): enable TypeScript strict (#11929)

This commit is contained in:
Germán Jabloñski
2025-04-03 10:01:13 -03:00
committed by GitHub
parent 06d937e903
commit a58ff57e4f
7 changed files with 10 additions and 14 deletions

View File

@@ -36,7 +36,7 @@ export const sendEmail = async (
if (emails && emails.length) {
const formattedEmails: FormattedEmail[] = await Promise.all(
emails.map(async (email: Email): Promise<FormattedEmail | null> => {
emails.map(async (email: Email): Promise<FormattedEmail> => {
const {
bcc: emailBCC,
cc: emailCC,

View File

@@ -23,6 +23,7 @@ export const generateSubmissionCollection = (
},
relationTo: formSlug,
required: true,
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
validate: async (value, { req: { payload }, req }) => {
/* Don't run in the client side */
if (!payload) {
@@ -40,7 +41,7 @@ export const generateSubmissionCollection = (
})
return true
} catch (error) {
} catch (_error) {
return 'Cannot create this submission because this form does not exist.'
}
}

View File

@@ -31,7 +31,7 @@ export const DynamicFieldSelector: React.FC<
return null
})
.filter(Boolean)
.filter((field) => field !== null)
setOptions(allNonPaymentFields)
}
}, [fields, getDataByPath])
@@ -40,9 +40,8 @@ export const DynamicFieldSelector: React.FC<
<SelectField
{...props}
field={{
name: props?.field?.name,
options,
...(props.field || {}),
options,
}}
/>
)

View File

@@ -57,11 +57,11 @@ export const generateFormCollection = (formConfig: FormBuilderPluginConfig): Col
],
})
if (redirect.fields[2].type !== 'row') {
redirect.fields[2].label = 'Custom URL'
if (redirect.fields[2]!.type !== 'row') {
redirect.fields[2]!.label = 'Custom URL'
}
redirect.fields[2].admin = {
redirect.fields[2]!.admin = {
condition: (_, siblingData) => siblingData?.type === 'custom',
}
}

View File

@@ -16,7 +16,7 @@ export const replaceDoubleCurlys = (str: string, variables?: EmailVariables): st
return variables.map(({ field, value }) => `${field} : ${value}`).join(' <br /> ')
} else if (variable === '*:table') {
return keyValuePairToHtmlTable(
variables.reduce((acc, { field, value }) => {
variables.reduce<Record<string, string>>((acc, { field, value }) => {
acc[field] = value
return acc
}, {}),

View File

@@ -106,7 +106,7 @@ export const serializeSlate = (children?: Node[], submissionData?: any): string
`
case 'link':
return `
<a href={${escapeHTML(replaceDoubleCurlys(node.url, submissionData))}}>
<a href={${escapeHTML(replaceDoubleCurlys(node.url!, submissionData))}}>
${serializeSlate(node.children, submissionData)}
</a>
`

View File

@@ -1,8 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
/* TODO: remove the following lines */
"strict": false,
},
"references": [{ "path": "../payload" }, { "path": "../ui" }]
}