-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interface does not satisfy the constraint FieldValues #2
Comments
Hey @kkharji, thank you for using Modular Forms! That means a lot to me. I am aware of this problem. If you use a The problem is that a form can be nested arbitrarily and I use a recursive type for that. Why TypeScript doesn't then accept an interface as generic, I don't know yet. If you are familiar with TypeScript, you can try to help me here. Otherwise I will ask for advice in the SolidJS community. |
Oh that sucks, I was hoping it was unknown issue. Yes, typescript advance type is hard to get right, let alone supporting No issues hopefully the rspc generator would be able to generate with Thanks @fabian-hiller |
I am sure there is a solution to this problem. I will try to fix it tomorrow. I will give you an update here. |
As described in this issue, the "problem" has existed in TypeScript for a very long time now. I am not yet aware of a user-friendly workaround that does not compromise type safety. I will let you know as soon as I find a solution. |
Until TypeScript gives us a "better" solution, I recommend using interface LoginForm {
email: string;
password: string;
[name: string]: string;
} interface LoginForm extends Record<string, string> {
email: string;
password: string;
} This may affect the editor support, so that e.g. autocomplete works only conditionally. If someone here knows TypeScript very well and thinks he or she can solve the problem by making changes to Modular Forms, I have prepared a minimal TypeScript playground for experimenting. I'm temporarily closing the issue until there are signs that changes to our code can fix the problem. |
I force to use interfaces with interface LoginForm extends FieldValues {
email: string;
password: string;
} |
All solutions I know so far to be able to support interfaces reduce type safety. I have again experimented a bit, but have not come to a satisfactory solution. |
Hello @fabian-hiller, very promising library and awesome documentation, thank you.
I'm using auto-generated interfaces for my types, but unfortunately I ran into an error:
The interface:
Thanks
The text was updated successfully, but these errors were encountered: