makeStyles overload breakage with TypeScript 4.1
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate. Possibly #14018
Current Behavior 😯
With today’s TypeScript 4.1 release, there’s an issue with makeStyles
that pops up:
import {createStyles, makeStyles} from '@material-ui/core/styles';
import React from 'react';
export function HeaderBreadcrumbs() {
const classes = useStyles();
// ~~~~~~~~~~~ Expected 1 arguments, but got 0. ts(2554)
return <div className={classes.outer}>Hello!</div>;
}
const useStyles = makeStyles(theme =>
createStyles({
outer: {
'& .MuiLink-root': {
...theme.typography.h6, // this line is key!
color: 'inherit',
},
},
}),
);
This passes the type checker with TS 4.0 but not TS 4.1, where you get this error:
Expected 1 arguments, but got 0. ts(2554)
An argument for 'props' was not provided.
This is being tracked on the TypeScript side over here: https://github.com/microsoft/TypeScript/issues/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 🌎
Tech | Version |
---|---|
Material-UI | v4.11.0 |
React | 16.13.1 |
Browser | n/a |
TypeScript | 4.1.2 |
etc. |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:11 (7 by maintainers)
Top Results From Across the Web
makeStyles overload breakage with TypeScript 4.1 #23627
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >Using makeStyles in material ui with typescript - Stack Overflow
No overload matches this call. Overload 1 of 2, '(style: Styles<any, {}, "root" | "expansionPanel ...
Read more >@material-ui/styles | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >this expression is not callable. type 'never' has no call ...
In TypeScript 4.1, the two signatures were considered "incompatible", so attempting to call the function would raise an error. TypeScript 4.2 improves this ......
Read more >front-end/node_modules/@material-ui/styles/CHANGELOG.md
Migrate more descriptions of the props to TypeScript (#20342) @eps1lon. ... [docs] makeStyles doesn't have access to the component's name (#19474) @hesto2 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/mui-org/material-ui/releases/tag/v4.11.1
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.