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

[TypeScript] Fix Field components types doesn't expose defaultProps & propTypes #6585

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Sep 13, 2021

Problem

Run the demo with make demo in the latest master. The TS compilation fails with a weird

Failed to compile.

~/react-admin/examples/demo/src/visitors/ColoredNumberField.tsx
TypeScript error in ~/react-admin/examples/demo/src/visitors/ColoredNumberField.tsx(15,47):
Property 'defaultProps' does not exist on type 'NamedExoticComponent'. TS2339

   14 | 
   15 | ColoredNumberField.defaultProps = NumberField.defaultProps;
      |                                               ^
   16 | 
   17 | export default ColoredNumberField;
   18 |

Solution

Partially reverts #6538 and come back to FC. Although it has the drawback of adding an implicit children prop even when it's not necessary, it's better than typing Fields with NamedExoticComponent.

@fzaninotto fzaninotto added the RFR Ready For Review label Sep 13, 2021
packages/ra-ui-materialui/src/field/ChipField.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/field/DateField.tsx Outdated Show resolved Hide resolved
@djhi djhi merged commit 1cb9a8d into master Sep 14, 2021
@djhi djhi deleted the TS-Field-components-memo-FC branch September 14, 2021 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants