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 AnyComponent for functional components. #12589

Merged
merged 1 commit into from
Aug 22, 2018
Merged

[typescript] Fix AnyComponent for functional components. #12589

merged 1 commit into from
Aug 22, 2018

Conversation

vierbergenlars
Copy link
Contributor

@vierbergenlars vierbergenlars commented Aug 20, 2018

A functional component does not return a ReactElement with the same props as its input, but a ReactElement with props of its child component.
The props of its child component can not be determined and are irrelevant for typing purposes.

This PR aligns the functional component type to match the one from react (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L343)

I can not reproduce this issue with codesandbox.io, but I am able to reproduce it after ejecting from create-react-app and using typescript 3.0.1 (as opposed to some 2.x version that is required by react-scripts-ts)

The reproduction is available at https://github.com/vierbergenlars/material-ui-repro-1, run npm install && npm run start to see the type error.

A functional component does not return a ReactElement with the same props as its input, but a ReactElement with props of its child component.
The props of its child component can not be determined and are irrelevant for typing purposes.
@pelotom
Copy link
Member

pelotom commented Aug 22, 2018

Looks good to me, thanks!

@pelotom pelotom merged commit 96d103e into mui:master Aug 22, 2018
marcelpanse pushed a commit to marcelpanse/material-ui that referenced this pull request Oct 2, 2018
A functional component does not return a ReactElement with the same props as its input, but a ReactElement with props of its child component.
The props of its child component can not be determined and are irrelevant for typing purposes.
@vierbergenlars vierbergenlars deleted the patch-1 branch October 13, 2018 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants