-
-
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
FieldProps not accepting an interface as generic #9102
Comments
For now we are using an adapter, but could this be implemented in react-admin side?
|
Thanks for reporting this. |
This bug challenges my comprehension of TypeScript generics and excess property checking. I've tried and tweaked an example provided by @slax57 in the TypeScript playground, but it only brings me perplexity. Now I've tested your proposed solution of using As for the |
According to my tests and research, the If you extend Those were my conclusions based on testing and language study and research. I would like to know your views on the subject. CC: I think this comment might clear our minds.
Indeed |
For what I understood, mainly by reading this long issue discussion in TS repo, there's a difference on how Typescript doesn't support implicit index signatures on interfaces. It only supports implicit index signatures on types. For interfaces, you need to explicit declare the index signature, like this:
But this also would make the below expression acceptable, even if we haven't declared
Since FieldProps new typing added a The |
I don't feel copmfortable about this change. I'll wait for the rest of the core team to come back from holidays so we can make a good decision (probably end of August). In the meantime, you can use the quick fix consisting of using |
What you were expecting:
On version 4.10.1, before updating to v4.12.1, the following code was working without errors:
What happened instead:
But then the following error started to appear:
This error doesn´t show if we define
A
as atype
or extends it fromRaRecord
orRecord<string, any>
.Related code:
https://codesandbox.io/s/beautiful-wescoff-rkt57q?file=/src/App.tsx
Other information:
I imagine that this started because of this change: https://marmelab.com/blog/2023/06/13/react-admin-june-2023-update.html#generic-field-components about generic field components.
But was this described scenario expected? Should we change all interfaces to types or make them extend from Record?
Environment
https://codesandbox.io/s/beautiful-wescoff-rkt57q?file=/src/App.tsx:0-398
The text was updated successfully, but these errors were encountered: