-
Notifications
You must be signed in to change notification settings - Fork 36
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
🐛[BUG] TypeScript: ThemeProvider type alias is returning the wrong type #163
Comments
|
I see. Sorry for the duplicate ticket. I'm using React 17 still. Typescript is at 4.6.3. I think it would be a good idea to add a warning to the documentation about this issue along with a workaround for users that are on older versions of React / TS. I'd be happy to put in a PR for that if it's ok to have English in the docs as well. |
@overthemike yeah, PR welcome~ |
🐛 bug description
ThemeProvider is currently expecting a return type of React.ReactNode when it should be using JSX.Element. I was creating an HOC for ThemeProvider so that I could keep customToken object in it's own file. ThemeProvider has it's return type as
ReactNode
which allows forundefined
which causes typescript to yell at you. I was able to get rid of the error by overriding the type alias to instead return JSX.Element, which doesn't allow for returningundefined
.📷 Steps to reproduce
I was able to fix it by overriding ThemeProvider's typeAlias and changing the return type from ReactNode to JSX.Element
🏞 Expected results
No errors when trying to use an HOC on ThemeProvider
💻 Reproduce code
All is listed above
© Version information
The text was updated successfully, but these errors were encountered: