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.

/core dependency on /types ^5.1.0 is too loose

See original GitHub issue

@material-ui/core depends on @material-ui/types@^5.1.0. The caret means that any 5.x version is allowed. If you actually try to use @material-ui/core, odd problems manifest.

  • The issue is present in the latest release. It’s present in the latest ‘stable’ release 4.11.3
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Trying to spread with DateTimePickerProps from MUI Pickers:

import { DateTimePickerProps } from '@material-ui/pickers';

// Get a DateTimePickerProps from somewhere
const t = null as unknown as DateTimePickerProps;
console.log(
  t.InputProps,           // This works
  { ...t }.InputProps,   // This also works
  { ...{}, ...t }.InputProps, // 'InputProps' does not exist on type ...
);

That third argument to console.log raises an error at compile time.

Expected Behavior 🤔

The spread should work fine.

Steps to Reproduce 🕹

Steps:

  1. Open https://codesandbox.io/s/mui-4113-types-dep-problem-8k1xv
  2. Wait for a moment for codesandbox to install things
  3. Note the error on the { ...{}, ...t } line
  4. Change the version of @material-ui/types in package.json to 5.1.6 and save it
  5. Wait a moment
  6. Note the error in index.d.ts goes away

Context 🔦

I’m trying to merge the picker props from our React code with props from Formik before passing them to MUI Pickers. I think any new install of MUI 4.x (without a lockfile) will encounter this problem.

The root cause, I believe, is that my project depends on @material-ui/core 4.11.3, which in turn depends on @material-ui/types ^5.1.0, which resolved to 5.1.7. This is because the type DateTimePickerProps ultimately uses types from OverridableComponent.d.ts, which tries to import Omit from @material-ui/types. However, as of 5.1.7, Omit was renamed to DistributiveOmit.

I think it’s a TypeScript bug to raise the error that it did, since the problem is actually that the type definitions in use are unsound, but I think there’s also a problem here in Material UI. The range on the dependency should probably be 5.1.0 - 5.1.6, or OverridableComponent.d.ts should change to import DistributiveOmit. I’ve verified that either change fixes the TypeScript error.

Your Environment 🌎

`npx @material-ui/envinfo`
  System:
    OS: macOS 11.2.1
  Binaries:
    Node: 15.10.0 - /usr/local/bin/node
    Yarn: 2.4.0-git.20210302.hash-04227fe7 - /usr/local/bin/yarn
    npm: 7.6.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 88.0.4324.192
    Edge: Not Found
    Firefox: 84.0.2
    Safari: 14.0.3

I’m using TypeScript 4.2.2. I can’t post our tsconfig, but the repro in codesandbox.io should suffice.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
eps1loncommented, Apr 27, 2021

Should be fixed in @material-ui/core@4.11.4

2reactions
eps1loncommented, Mar 29, 2021

We should fix the prior mistake and bump it to v6. Trying to think of a way to prevent these mistakes in the future. Will wait for another incident to come up with a good solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installation fails for @types/<dependency_name> packages
Attempt to initialise with the yarn command when there are @types/<dependency_name> dependencies in package.json , for example: { "name": "opus.
Read more >
Problem with npm install - Could not resolve dependency. Is ...
I tried to launch --legacy-peer-deps but this creates a package-lock.json with "lockfileVersion" setted to 2. I want to create a regular ...
Read more >
History of Changes - Apache POI
Upgrade log4j-api dependency to 2.19.0; Upgrade xmlsec dependency to 3.0.1 ... fix, 65950, POI_Overall, POI 5.2.1 can allocate byte arrays that are too...
Read more >
Gatsby Changelog | 5.3.0
Fix graphql@16 peer dependency problems by migrating from express-graphql to graphql-http , via PR #37001; Use XState predictableActionArguments and upgrade to ...
Read more >
DataStax Enterprise 5.1 release notes | DSE 5.1 Dev guide
Check of two versions of metadata for a column fails on upgrade from DSE 5.0.x when type is not of same class. Loosen...
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