What is the correct way to use `withForm` with additional props?
I have the following code:
The casting seems wrong, is there a better way to define additional props?
4 Replies
conscious-sapphire•3mo ago
you technically can extract it the same way as
defaultValues
:
however, these are never going to be runtime values, so you don't need to assign it actual values.
This would be fine:
but it will throw a typescript error as interfaces are not indexable (and therefore not assignable to Records). Use a type instead:
extended-salmonOP•3mo ago
Gotcha, makes sense! I’m using types so the last option works great, just felt a bit weird
And yeah could call form.onSubmit, this was mostly generated by AI so have to clean it up 😉
conscious-sapphire•3mo ago
understandable! The reason this assertion is required is because partial inheritance doesn't exist for typescript yet
so you can't add one generic and infer the rest, it's either all or none
also make sure to feed the markdown versions of guides to LLMs (add
.md
to the link)
they may be out of date on TSF stuffextended-salmonOP•3mo ago
Ahhhh yeah that makes sense, I was going to ask what it can’t be a generic parameter