question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
oliviertassinaricommented, Nov 24, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found