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] Incorrect children type for CssBaseline and ScopedCssBaseline #19767

Closed
2 tasks done
dfernandez-asapp opened this issue Feb 18, 2020 · 1 comment · Fixed by #19770
Closed
2 tasks done
Labels
component: CssBaseline The React component good first issue Great for first contributions. Enable to learn the contribution process. typescript

Comments

@dfernandez-asapp
Copy link
Contributor

The children property is declared as ReactElement and it should be the more general ReactNode.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

const App : React.FC = ({children}) => <CssBaseline>{children}</CssBaseline>

This example fails with the current typings. It should work.

Also PropTypes in CssBaseline uses node.

Expected Behavior 🤔

The previous example should pass the typechecking.

Steps to Reproduce 🕹

https://codesandbox.io/s/exciting-bohr-7nceq

Steps:

  1. Create a TypeScript project
  2. Add latest release of MUI (4.93)
  3. Create a functional component like the one in the example
  4. Pass children to CssBaseline or ScopedCssBaseline

Context 🔦

I'm trying to create a generic app component that does the setup of MUI theme and styles.

Your Environment 🌎

Tech Version
Material-UI v4.9.3
React 16.12.0
TypeScript 3.7.5
@types/react 16.9.20
@eps1lon
Copy link
Member

eps1lon commented Feb 18, 2020

You're totally right. Do you mind working on a PR?

@eps1lon eps1lon added component: CssBaseline The React component good first issue Great for first contributions. Enable to learn the contribution process. typescript labels Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: CssBaseline The React component good first issue Great for first contributions. Enable to learn the contribution process. typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants