fabian-hiller / modular-forms

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

[solidjs][typescript] Getting typing right in the LoginForm example #219

Closed nicoknoll closed 4 months ago

nicoknoll commented 4 months ago

Hi, I'm just trying to get typing working but somehow even the LoginForm typescript example leads to errors.

My main issue is getting typing for the FormStore<FieldValues> right. One of the issues Intellij gives me is that it always requires the second argument (Generic type 'FormStore' requires '2' type argument(s)) which seems to be easy to fix. But even when this is fixed the fields "of" parameter always complains with Type FormStore<LoginForm> is not assignable to type FormStore<TFieldValues, TResponseData> as well as the children render method Type (field: any, props: any) => JSX.Element is not assignable to type <TFieldValues, TFieldName>(store: FieldStore<TFieldValues, TFieldName>, props: FieldElementProps<TFieldValues, TFieldName>) => JSX.Element.

Bildschirmfoto 2024-06-21 um 14 00 43

Let me know if I can add any more information to reproduce this.

fabian-hiller commented 4 months ago

Can you send me a StackBlitz link? You can use this as a template: https://stackblitz.com/edit/modular-forms-solid?file=src/routes/login.tsx

fabian-hiller commented 4 months ago

Please make sure that the libraries you are using are up to date.

nicoknoll commented 4 months ago

Thanks for the fast reply. I copied the content from the guide (https://modularforms.dev/solid/guides/typescript) into stackblitz and it shows the same typescript errors (it is running though): https://stackblitz.com/edit/modular-forms-solid-dkgdkw?file=src%2Fapp.tsx,src%2FLoginPage.tsx

Bildschirmfoto 2024-06-21 um 20 08 50

fabian-hiller commented 4 months ago

Thank you very much! I will look into this issue. For now, here is a workaround: https://stackblitz.com/edit/modular-forms-solid-owzxu8?file=src%2Fapp.tsx,src%2FLoginPage.tsx

nicoknoll commented 4 months ago

Nice, thanks a lot so far!

fabian-hiller commented 4 months ago

This is fixed now. Thanks!