-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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/getting-started/supported-platforms/supported-platforms-es.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 }) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
packages/material-ui/src/TextareaAutosize/TextareaAutosize.d.ts
Outdated
Show resolved
Hide resolved
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
e0f0807
to
8a6f1fd
Compare
8a6f1fd
to
d3e2487
Compare
Looking at it tomorrow. |
I have pushed an update to mention the change of TypeScript version in the migration guide as a standalone entry.
@eps1lon Do you mean that you have approved the changes too quickly? |
I have not approved all changes. |
If this is needed for something we can work on it in a follow-up with tests
Added a rationale for the bump in TS version (focusing on the link to the DT repo). |
@petyosi Thanks! |
@@ -1,4 +1,5 @@ | |||
import * as React from 'react'; | |||
import { DistributiveOmit } from '@material-ui/types'; |
There was a problem hiding this comment.
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
Breaking changes
Omit
type in@material-ui/types
. The module is now calledDistributiveOmit
. The change removes the confusion with the built-inOmit
helper introduced in TypeScript v3.5. The built-inOmit
, while similar, is non-distributive. This leads to differences when applied to union types. See this StackOverflow answer for further details.As per #24752 (comment),
built-in
Omit
usage should be considered a bug. There's one exception tothat 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.