[typescript] Fix AnyComponent for functional components. #12589
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.