pablo-abc / felte

An extensible form library for Svelte, Solid and React
https://felte.dev
MIT License
1.02k stars 44 forks source link

Type error when using Yup validator #153

Open AnatoleLucet opened 2 years ago

AnatoleLucet commented 2 years ago

Describe the bug

Not sure if this is a bug or me not doing this correctly, but I get a type error when trying to validate my form with Yup

Which package/s are you using?

felte (Svelte), @felte/validator-yup

Environment

Latest version of Felte, @felte/validator-yup and Yup

To reproduce

No response

Small reproduction example

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYygUwIYzQMWiOAXzgDMoICAiEtAG20oG4AoUSWROANw1uABMs0IqXJUAAjXpoA9Dz6CY0ALQBPAK5gmrcNHgAqOBgDOcDWFEU4lc9tYA7bFBIZkaOHiggAIlgyJmOCDSCAgALjhjGChgewBzFkJmZlRMbE8QAB4M3xgMAD4ACgRA4Ih7AGV1ACMQYBgIwvl1NGMASjgAXnyA4KIAGlKgtAAPbHt+CIBtIb7uXgEhKGLZueDjZAALNBAMCPMAOghqgCs0ZBhCtoPjTYwwNBW15+CSUP3NG+jYuKuD9AAjupgOh+FdBi8+oQ2iwXtCIcEALqDaGMIA

Screenshots

No response

Additional context

No response

pablo-abc commented 2 years ago

Hey! This seems to be fixed by using type FormData = { /*... */ } instead of interface FormData. This seems to be due to how interfaces work and how types are defined within Felte.

I'd recommend using type in this case. I'd have to read more to see if there's a way to make interfaces work.