Skip to content

Commit a58ff57

Browse files
authored
chore(plugin-form-builder): enable TypeScript strict (#11929)
1 parent 06d937e commit a58ff57

File tree

7 files changed

+10
-14
lines changed

7 files changed

+10
-14
lines changed

packages/plugin-form-builder/src/collections/FormSubmissions/hooks/sendEmail.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const sendEmail = async (
3636

3737
if (emails && emails.length) {
3838
const formattedEmails: FormattedEmail[] = await Promise.all(
39-
emails.map(async (email: Email): Promise<FormattedEmail | null> => {
39+
emails.map(async (email: Email): Promise<FormattedEmail> => {
4040
const {
4141
bcc: emailBCC,
4242
cc: emailCC,

packages/plugin-form-builder/src/collections/FormSubmissions/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const generateSubmissionCollection = (
2323
},
2424
relationTo: formSlug,
2525
required: true,
26+
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
2627
validate: async (value, { req: { payload }, req }) => {
2728
/* Don't run in the client side */
2829
if (!payload) {
@@ -40,7 +41,7 @@ export const generateSubmissionCollection = (
4041
})
4142

4243
return true
43-
} catch (error) {
44+
} catch (_error) {
4445
return 'Cannot create this submission because this form does not exist.'
4546
}
4647
}

packages/plugin-form-builder/src/collections/Forms/DynamicFieldSelector.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const DynamicFieldSelector: React.FC<
3131

3232
return null
3333
})
34-
.filter(Boolean)
34+
.filter((field) => field !== null)
3535
setOptions(allNonPaymentFields)
3636
}
3737
}, [fields, getDataByPath])
@@ -40,9 +40,8 @@ export const DynamicFieldSelector: React.FC<
4040
<SelectField
4141
{...props}
4242
field={{
43-
name: props?.field?.name,
44-
options,
4543
...(props.field || {}),
44+
options,
4645
}}
4746
/>
4847
)

packages/plugin-form-builder/src/collections/Forms/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ export const generateFormCollection = (formConfig: FormBuilderPluginConfig): Col
5757
],
5858
})
5959

60-
if (redirect.fields[2].type !== 'row') {
61-
redirect.fields[2].label = 'Custom URL'
60+
if (redirect.fields[2]!.type !== 'row') {
61+
redirect.fields[2]!.label = 'Custom URL'
6262
}
6363

64-
redirect.fields[2].admin = {
64+
redirect.fields[2]!.admin = {
6565
condition: (_, siblingData) => siblingData?.type === 'custom',
6666
}
6767
}

packages/plugin-form-builder/src/utilities/replaceDoubleCurlys.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const replaceDoubleCurlys = (str: string, variables?: EmailVariables): st
1616
return variables.map(({ field, value }) => `${field} : ${value}`).join(' <br /> ')
1717
} else if (variable === '*:table') {
1818
return keyValuePairToHtmlTable(
19-
variables.reduce((acc, { field, value }) => {
19+
variables.reduce<Record<string, string>>((acc, { field, value }) => {
2020
acc[field] = value
2121
return acc
2222
}, {}),

packages/plugin-form-builder/src/utilities/slate/serializeSlate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const serializeSlate = (children?: Node[], submissionData?: any): string
106106
`
107107
case 'link':
108108
return `
109-
<a href={${escapeHTML(replaceDoubleCurlys(node.url, submissionData))}}>
109+
<a href={${escapeHTML(replaceDoubleCurlys(node.url!, submissionData))}}>
110110
${serializeSlate(node.children, submissionData)}
111111
</a>
112112
`
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"compilerOptions": {
4-
/* TODO: remove the following lines */
5-
"strict": false,
6-
},
73
"references": [{ "path": "../payload" }, { "path": "../ui" }]
84
}

0 commit comments

Comments
 (0)