Skip to content

Commit

Permalink
[typescript] Fix AnyComponent for functional components. (#12589)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vierbergenlars authored and pelotom committed Aug 22, 2018
1 parent 9bd1e8e commit 96d103e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/material-ui/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { StyledComponentProps };

export type AnyComponent<P = any> =
| (new (props: P) => React.Component)
| ((props: P & { children?: React.ReactNode }) => React.ReactElement<P> | null);
| ((props: P & { children?: React.ReactNode }) => React.ReactElement<any> | null);

export type PropsOf<C extends AnyComponent> = C extends new (props: infer P) => React.Component
? P
Expand Down

0 comments on commit 96d103e

Please sign in to comment.