chore(plugin-form-builder): enable TypeScript strict (#11929)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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.'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}, {}),
|
||||
|
||||
@@ -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>
|
||||
`
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
/* TODO: remove the following lines */
|
||||
"strict": false,
|
||||
},
|
||||
"references": [{ "path": "../payload" }, { "path": "../ui" }]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user