-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[v4.0.0-rc.1] SelectInput onChange type incorrect #7518
Comments
Hi! Thank you for submitting this. Actually the full type shown by TS is: But you are right when you say that in RA the argument passed to this function will always be the input's value. In the docs we do not explicit what this function expects, and in TS I believe the type is not fundamentally wrong, although the fact that the argument is called |
The problem is that if I try:
This does work:
(I use unknown[] as my company has linting for 'no-explicit-any'). Either way, if an option on typing is to use a ChangeEventHandler, it should either return a ChangeEvent or not offer that as a type IMO? Offering a ChangeEventHandler but returning an unexpected type is a recipe for problems. |
Indeed you are totally right @vespasianvs , I missed that point. |
What you were expecting:
The typing for the onChange handler for SelectInput is shown as:
React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined
This should return an event of type: React.ChangeEvent<HTMLInputElement | HTMLTextAreaAlement>
What happened instead:
A string is returned with the value that the select was changed to.
Steps to reproduce:
While using Typescript, add a SelectInput to an Edit -> SimpleForm and then add an onChange handler. Typescript marks onChange as above, but the return value doesn't match.
Related code:
Happy to fix and do a PR, but not sure whether the typing is incorrect and a string should be returned, or whether the the typing is correct and an event should be returned.
Environment
The text was updated successfully, but these errors were encountered: