Skip to content
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

[types] Bump minimum required TypeScript version to 3.5 #24795

Merged
merged 7 commits into from
Feb 11, 2021

Conversation

petyosi
Copy link
Contributor

@petyosi petyosi commented Feb 6, 2021

Breaking changes

  • [core] Increase the minimum version of TypeScript supported from v3.2 to v3.5.
  • [@material-ui/types] Rename the exported Omit type in @material-ui/types. The module is now called DistributiveOmit. The change removes the confusion with the built-in Omit helper introduced in TypeScript v3.5. The built-in Omit, while similar, is non-distributive. This leads to differences when applied to union types. See this StackOverflow answer for further details.
-import { Omit } from '@material-ui/types';
+import { DistributiveOmit } from '@material-ui/types';

As per #24752 (comment),
built-in Omit usage should be considered a bug. There's one exception to
that in packages/material-ui-lab/src/DayPicker/PickersSlideTransition.tsx.

This change also removes the Omit export from the package. The documentation examples resort to the built-in Omit. Let me know if this makes sense.

@mui-pr-bot
Copy link

mui-pr-bot commented Feb 6, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 7228d94

@oliviertassinari oliviertassinari added typescript core Infrastructure work going on behind the scenes labels Feb 7, 2021
@oliviertassinari oliviertassinari changed the title [typescript] Fix Omit / DistributiveOmit ambiguity [core] Fix Omit/DistributiveOmit TypeScript ambiguity Feb 7, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the confusion between the two helpers is great. How about we update the documentation of https://next.material-ui.com/getting-started/supported-platforms/#typescript as we rely on TypeScript 3.5 now for the built-in omit?

I think that such breaking change should also have its entry in the migration guide. Alternatively, we could do it in two different PRs (1. Bump TypeScript, 2. Omit confusion). I have no specific preferences.

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the second migration notice, I think that we could have it close to this section: https://next.material-ui.com/guides/migration-v4/#supported-browsers-and-node-versions.

docs/src/pages/guides/migration-v4/migration-v4.md Outdated Show resolved Hide resolved
docs/src/pages/guides/migration-v4/migration-v4.md Outdated Show resolved Hide resolved
@@ -75,7 +76,7 @@ export const getMinutesNumbers = ({
value,
isDisabled,
getClockNumberText,
}: Omit<GetHourNumbersOptions, 'ampm' | 'date'> & { value: number }) => {
}: DistributiveOmit<GetHourNumbersOptions, 'ampm' | 'date'> & { value: number }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were using the built-in Omit helper previously. Why change it for the distributive one? I guess it's the same question for all the other cases. When should we use one over the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through all occurances and applied the following:

  • If applied to an interface, use the built-in Omit, since the distributive one has no effect;
  • If applied to a union type or to a generic parameter, use DistributiveOmit.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 7, 2021
As per mui#24752 (comment),
built-in Omit usage should be considered a bug. There's one exception to
that in packages/material-ui-lab/src/DayPicker/PickersSlideTransition.tsx
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 8, 2021
@eps1lon eps1lon changed the title [core] Fix Omit/DistributiveOmit TypeScript ambiguity [types] Fix Omit/DistributiveOmit TypeScript ambiguity Feb 8, 2021
@eps1lon eps1lon added breaking change package: material-ui Specific to @mui/material package: types Specific to @mui/types and removed core Infrastructure work going on behind the scenes labels Feb 8, 2021
@eps1lon
Copy link
Member

eps1lon commented Feb 8, 2021

Looking at it tomorrow.

@oliviertassinari
Copy link
Member

I have pushed an update to mention the change of TypeScript version in the migration guide as a standalone entry.

Looking at it tomorrow.

@eps1lon Do you mean that you have approved the changes too quickly?

@eps1lon
Copy link
Member

eps1lon commented Feb 8, 2021

@eps1lon Do you mean that you have approved the changes too quickly?

I have not approved all changes.

@eps1lon eps1lon self-requested a review February 11, 2021 11:14
If this is needed for something we can work on it in a follow-up with tests
@eps1lon
Copy link
Member

eps1lon commented Feb 11, 2021

Added a rationale for the bump in TS version (focusing on the link to the DT repo).
Also reverted a bunch of changes where DistributiveOmit was added. In these instance we either know that the input isn't a union or the behavior is new. If we want to change it, we should do so with a test.

@eps1lon eps1lon changed the title [types] Fix Omit/DistributiveOmit TypeScript ambiguity [types] Bump minimum required TypeScript version to 3.5 Feb 11, 2021
@eps1lon eps1lon merged commit 058e409 into mui:next Feb 11, 2021
@eps1lon
Copy link
Member

eps1lon commented Feb 11, 2021

@petyosi Thanks!

@@ -1,4 +1,5 @@
import * as React from 'react';
import { DistributiveOmit } from '@material-ui/types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@material-ui/types isn't declared as a dependency of the package. It creates this fail: mui/mui-x#1046. Solved in #24936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change package: material-ui Specific to @mui/material package: types Specific to @mui/types typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants