modular-forms icon indicating copy to clipboard operation
modular-forms copied to clipboard

Typescript Errors

Open robodna opened this issue 1 year ago • 6 comments

I see a typescript warning on 'field' and 'props' for the following:

<Field name="owner" validate={required('Please enter your name.')}> {(field, props) => (

I tried setting to the following but still get an error:

field:FieldStore, props:FieldElementProps

What am I doing wrong?

Thanks

robodna avatar Jul 09 '24 15:07 robodna

Does required<string>('Please enter your name.') fix it?

fabian-hiller avatar Jul 10 '24 21:07 fabian-hiller

It is the <Field>'s child function that throws Typscript warnings:

field:FieldStore, props:FieldElementProps

robodna avatar Jul 10 '24 23:07 robodna

I need more of your code or a reproduction on Stackblitz. What framework are you using?

fabian-hiller avatar Jul 11 '24 09:07 fabian-hiller

I"m using SolidJS. Typescript does not like FieldStore or FieldElementProps as types. The both have an underline in red in VisualStudioCode. I just set them both to :any to hide the warnings.

robodna avatar Jul 11 '24 10:07 robodna

Feel free to create a reproduction using this template: https://stackblitz.com/edit/modular-forms-solid?file=src%2Froutes%2Flogin.tsx

fabian-hiller avatar Jul 13 '24 13:07 fabian-hiller

I'll have to investigate further since some components do not show the Typescript warning, but some do. It may have to do with the <Form element being in a separate component instead of in the same component as the <Field elements. I have a component to render the start of the <Form, and then another component which renders the <Field components.

robodna avatar Jul 13 '24 14:07 robodna