You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When TypeScript compiler option exactOptionalPropertyTypes is set to true, you cannot pass undefined as a value to an object property that is marked as optional. While IMO very useful option, it can lead to bad DX, because it can cause TypeScript errors:
import{useForm}from'@conform-to/react';typeCustomComponentProps={onSubmit?: Parameters<typeofuseForm>[0]['onSubmit']|undefined;}letCustomComponent=({onSubmit}: CustomComponentProps)=>{let[form]=useForm({
onSubmit // error here, because `onSubmit` prop can be `undefined`});// rest of the component}
I therefore prefer that "input" types (like function parameters, properties in options objects, etc.) have explicit undefined added to them; e.g. here I would like to have this:
exporttypeFormOptions<SchemaextendsRecord<string,any>=any,FormError=string[],FormValue=Schema,>=BaseFormOptions<Schema,FormError,FormValue>&{/** * A function to be called before the form is submitted. */onSubmit?: ((event: FormEvent<HTMLFormElement>,context: ReturnType<BaseFormContext<Schema,FormError,FormValue>['submit']>,)=>void)|undefined;// here I added explicit `undefined` to the type ⚠️};
Would it be possible to add undefined to all input types? Thank you.
Conform version
v1.1.5
Steps to Reproduce the Bug or Issue
What browsers are you seeing the problem on?
No response
Screenshots or Videos
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug and the expected behavior
When TypeScript compiler option
exactOptionalPropertyTypes
is set totrue
, you cannot passundefined
as a value to an object property that is marked as optional. While IMO very useful option, it can lead to bad DX, because it can cause TypeScript errors:I therefore prefer that "input" types (like function parameters, properties in options objects, etc.) have explicit
undefined
added to them; e.g. here I would like to have this:Would it be possible to add
undefined
to all input types? Thank you.Conform version
v1.1.5
Steps to Reproduce the Bug or Issue
What browsers are you seeing the problem on?
No response
Screenshots or Videos
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: