Skip to content
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

Usage of keyof in TypeScript types does not align with field names #485

Open
Christian24 opened this issue Oct 6, 2023 · 0 comments
Open

Comments

@Christian24
Copy link

Are you submitting a bug report or a feature request?

This is a bug report

What is the current behavior?

The TypeScript types for field names make extensive use of keyof operator. For an example look here. The keyof operator allows to limit the possible values of a string to the keys of an object. However, according to the documentation, nested paths are also supported. However, these are not supported by keyof operator. So in Typescript correct field names cannot be nested. For example a key like person.firstName cannot be specified, TypeScript will throw an error here.

What is the expected behavior?

Field names that are valid as per the documentation should also be possible TypeScript field names.

Other information

It seems React-Hook-Form has cracked the code of how to make this work: https://github.com/react-hook-form/react-hook-form/blob/5fef1f27d503e6bd49672ded5b1233fa0eb0ec92/src/types/form.ts#L526 Their types look very complex as well though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant