fabian-hiller / modular-forms

The modular and type-safe form library for SolidJS, Qwik and Preact
https://modularforms.dev
MIT License
970 stars 49 forks source link

Typescript Errors #223

Open robodna opened 1 month ago

robodna commented 1 month ago

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

fabian-hiller commented 1 month ago

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

robodna commented 1 month ago

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

field:FieldStore, props:FieldElementProps

fabian-hiller commented 1 month ago

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

robodna commented 1 month ago

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.

fabian-hiller commented 1 month ago

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

robodna commented 1 month ago

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.