-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
makeStyles overload breakage with TypeScript 4.1 #23627
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
Comments
I got same problem. 😢 |
I tried fix node_modules/@material-ui/core/styles/makeStyles.d.ts for debug. /**
* `makeStyles` where the passed `styles` do not depend on props
*/
export default function makeStyles<Theme = DefaultTheme, ClassKey extends string = string>(
style: Styles<Theme, {}, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
): (props?: any) => ClassNameMap<ClassKey>;
/**
* `makeStyles` where the passed `styles` do depend on props
*/
export default function makeStyles<
Theme = DefaultTheme,
Props extends {} = {},
ClassKey extends string = string
>(
styles: Styles<Theme, Props, ClassKey>,
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>
): (
- props: Props
+ props?: Props
) => ClassNameMap<ClassKey>; Type error was solved. |
Can confirm in our own codebase now. We actually do run tests with TS canaries. But this particular error was hidden by another, less severe error. In the future we should be able to anticipate these regressions better. |
Experiencing the same issue; where the culprit for me was ...theme.mixins.toolbar spreading the object ...theme.mixins.toolbar gives
so for now ive just appended those lines in place of the spread
|
Can this be fixed in Version 4, please? |
@ldrick Do you want to open a pull request for it on master? |
Done #23692. It's unclear when we will release the changes. The simplest would be to wait around Q1 2021 https://twitter.com/olivtassinari/status/1328346262505205768. So we have enough deprecations to release. |
I want to use of the combination of Typescript 4.1 and Material-UI as soon as possible, do you have any ideas? |
Ahh that's a bummer - I was also hoping for a soon v4 release of this as we will need to work on many upgrades like Typescript 4.1, react 17, ... and preparing for the Material UI v5 release 🎉 . Waiting until Q1 would mean also hold off on all other upgrades and then we would need to do all at once 🙈 - so if there is away (other than sprinkling @ts-ignores over all components) that would be much appreciated 🙏🏻 |
Yeah, in hindsight, I think that we will do something this week. We still need to add support for React v17 and we can release. |
Current Behavior 😯
With today's TypeScript 4.1 release, there's an issue with
makeStyles
that pops up:This passes the type checker with TS 4.0 but not TS 4.1, where you get this error:
This is being tracked on the TypeScript side over here: microsoft/TypeScript#41099
Unclear to me if this is a TS problem or a MUI problem, but it can't hurt to have linked issues on both repos!
Expected Behavior 🤔
No type error (the code works fine at runtime)
Steps to Reproduce 🕹
See code above and in linked issue.
Context 🔦
TypeScript 4.1 update
Your Environment 🌎
The text was updated successfully, but these errors were encountered: