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.

TypeScript errors upgrading MUI from 4.9.5 to 4.9.9

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.

Current Behavior 😯

I have been able to trace the following errors to some changes made recently to use TS features such as Omit which aren’t available in 3.2.4 (as far as I understand, that’s the minimum TS version that MUI supports) or trailing commas:

Click to expand
node_modules/@material-ui/core/Backdrop/Backdrop.d.ts:8:52 - error TS2304: Cannot find name 'Omit'.

8     React.HTMLAttributes<HTMLDivElement> & Partial<Omit<FadeProps, 'children'>>,
                                                     ~~~~

node_modules/@material-ui/core/Box/Box.d.ts:29:22 - error TS1009: Trailing comma not allowed.

29     typeof typography,
                        ~

node_modules/@material-ui/core/Fade/Fade.d.ts:4:36 - error TS2304: Cannot find name 'Omit'.

4 export interface FadeProps extends Omit<TransitionProps, 'children'> {
                                     ~~~~

node_modules/@material-ui/core/TextareaAutosize/TextareaAutosize.d.ts:4:11 - error TS2304: Cannot find name 'Omit'.

4   extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'children' | 'rows'> {
            ~~~~

node_modules/@material-ui/core/styles/shadows.d.ts:26:9 - error TS1009: Trailing comma not allowed.

26   string,
           ~


Expected Behavior 🤔

Steps to Reproduce 🕹

Steps:

  1. Install @material-ui/core@4.9.9
  2. Run your project through tsc using typescript@3.2.4
  3. Observe the errors above

Context 🔦

We set a minimum supported version of TypeScript to 3.2.4 in our design system to match Material-UI but seems like the latest MUI version uses newer TypeScript features. This isn’t usually a big issue to React projects, but we also support Angular teams via Custom Elements and usually bumping TypeScript requires them to bump their Angular versions too (usually across major version boundaries) which can be a bit painful. For example, Angular 7.2 supports TS 3.2.4, Angular 8.0.0 adds support for 3.4 dropping support for older versions, Angular 9.0.0 requires 3.6/3.7

Your Environment 🌎

Tech Version
Material-UI v4.9.9
TypeScript v3.2.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
eps1loncommented, Apr 6, 2020

Yeah this is what we wanted to avoid but I’d argue that this is more of an issue with a PR that was too big not the tooling.

I would rather move forward here though (upcoming @ts-expect-error and tslint -> eslint). Usage numbers for earlier typescript version is pretty low so I don’t think it’s justified to build tooling for 3.2. But this is for me personally. If wants to build it I’m all ears.

1reaction
oliviertassinaricommented, Apr 6, 2020

@eps1lon I wanted to ask about this a couple of days ago, this is an opportunity. What do you think about this diff?

diff --git a/docs/src/pages/getting-started/supported-platforms/supported-platforms.md b/docs/src/pages/getting-started/supported-platforms/supported-platforms.md
index befc4ca39..e49aeba94 100644
--- a/docs/src/pages/getting-started/supported-platforms/supported-platforms.md
+++ b/docs/src/pages/getting-started/supported-platforms/supported-platforms.md
@@ -36,3 +36,9 @@ It's a must-do for static pages, but it needs to be put in balance with not doin

 Material-UI supports the most recent versions of React, starting with ^16.8.0 (the one with the hooks).
 Have a look at the older [versions](https://material-ui.com/versions/) for backward compatibility.
+
+## TypeScript
+
+Material-UI supports the most recent versions of TypeScript.
+However, the codebase doesn't follow semver for types.
+You can expect breaking changes between two minor versions.
+As of now, we support TypeScript ^3.8.0.
+Have a look at the older [versions](https://material-ui.com/versions/) for backward compatibility.
diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json
index e682bb751..0b43f57b5 100644
--- a/packages/material-ui/package.json
+++ b/packages/material-ui/package.json
@@ -39,9 +39,13 @@
   "peerDependencies": {
     "@types/react": "^16.8.6",
     "react": "^16.8.0",
-    "react-dom": "^16.8.0"
+    "react-dom": "^16.8.0",
+    "typescript": "^3.8.0"
   },
   "peerDependenciesMeta": {
+    "typescript": {
+      "optional": true
+    },
     "@types/react": {
       "optional": true
     }
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript errors upgrading MUI from 4.9.5 to 4.9.9 #20441
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 >
MUI Versions
When updating to a new major release, you may need to run update scripts, refactor code, run additional tests, and learn new APIs....
Read more >
@material-ui/core - npm
React components that implement Google's Material Design.. Latest version: 4.12.4, last published: 9 months ago.
Read more >
material-ui/core/CHANGELOG.md - UNPKG
The change makes it easier for developers to upgrade React independently from Material-UI. The best support for React 17 will be found in...
Read more >
Mui Layout - v4 - CodeSandbox
Good news, mui-layout has been upgraded to @mui-treasury/layout with a lot of cool features coming! 1. 18.6k.
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