Why does formOptions return FormOptions | undefined? #1210
-
Curious if having parm and returntype for formOptions optional was intentional? form/packages/form-core/src/formOptions.ts Lines 7 to 33 in 72b4572 This means we can call formOptions with no actual options? This also then raises the question of why withForm, accepts TRenderProps extends Record<string, unknown> for props? This allows us to spread any random object of Record<string, unknown> like this, which I would've expected to see a type error. Probably some TS wizardry I'm not aware of? This also plays into #1201 since now when we pass in formOptions I have to assert they're not undefined or for some reason spreading them works? const fieldOpts = fieldOptions({ formOptions: formOpts!, ...})
// without the ! after formOpts we get a type error since we don't accept undefined in the new API, (which I think we shouldn't accept?)
const fieldOpts = fieldOptions({ formOptions: { ...formOpts }, ...}) // also works without any type errors. Opened as a broader discussion since it's not just specific to the PR |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Not intentional. Happy to get fixes for both/either. 😄 Thanks for this! |
Beta Was this translation helpful? Give feedback.
Not intentional. Happy to get fixes for both/either. 😄 Thanks for this!