From 058e409679188b9b5d68baeabea9f46b21f7fe1f Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Thu, 11 Feb 2021 14:00:03 +0200 Subject: [PATCH] [types] Bump minimum required TypeScript version to 3.5 (#24795) Co-authored-by: Olivier Tassinari Co-authored-by: eps1lon --- .../pages/css-in-js/basics/AdaptingHook.tsx | 1 - .../basics/AdaptingStyledComponents.tsx | 1 - .../supported-platforms.md | 2 +- .../pages/guides/composition/ButtonRouter.tsx | 1 - .../pages/guides/composition/LinkRouter.tsx | 1 - .../pages/guides/composition/ListRouter.tsx | 1 - .../pages/guides/migration-v4/migration-v4.md | 16 ++++++++++++++++ .../premium-themes/paperbase/Navigator.tsx | 1 - docs/src/pages/styles/basics/AdaptingHOC.tsx | 1 - docs/src/pages/styles/basics/AdaptingHook.tsx | 1 - .../basics/AdaptingStyledComponents.tsx | 1 - .../material-ui-lab/src/TabList/TabList.d.ts | 4 ++-- .../src/makeStyles/makeStyles.d.ts | 1 - .../material-ui-styles/src/styled/styled.d.ts | 4 ++-- .../src/withTheme/withTheme.d.ts | 7 +++++-- .../src/styleFunctionSx/styleFunctionSx.d.ts | 3 --- packages/material-ui-types/index.d.ts | 7 ++++--- .../src/OverridableComponent.d.ts | 6 +++--- .../material-ui-utils/src/isMuiElement.d.ts | 6 +++++- .../material-ui/src/Backdrop/Backdrop.d.ts | 2 +- packages/material-ui/src/Fade/Fade.d.ts | 1 - .../src/GlobalStyles/GlobalStyles.d.ts | 4 ++-- packages/material-ui/src/Grow/Grow.d.ts | 1 - packages/material-ui/src/Link/Link.d.ts | 4 ++-- .../material-ui/src/MenuItem/MenuItem.d.ts | 4 ++-- .../material-ui/src/OverridableComponent.d.ts | 6 +++--- packages/material-ui/src/Popper/Popper.d.ts | 1 - .../src/SwipeableDrawer/SwipeableDrawer.d.ts | 1 - .../src/TablePagination/TablePagination.d.ts | 1 - .../TextareaAutosize/TextareaAutosize.d.ts | 1 - packages/material-ui/src/index.d.ts | 19 ++++++------------- .../src/styles/experimentalStyled.d.ts | 1 - .../material-ui/src/styles/makeStyles.d.ts | 4 ++-- packages/material-ui/src/styles/styled.d.ts | 6 +++--- 34 files changed, 59 insertions(+), 62 deletions(-) diff --git a/docs/src/pages/css-in-js/basics/AdaptingHook.tsx b/docs/src/pages/css-in-js/basics/AdaptingHook.tsx index f439dbcdb8737d..6b12985140d093 100644 --- a/docs/src/pages/css-in-js/basics/AdaptingHook.tsx +++ b/docs/src/pages/css-in-js/basics/AdaptingHook.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Button, { ButtonProps as MuiButtonProps } from '@material-ui/core/Button'; -import { Omit } from '@material-ui/types'; interface Props { color: 'red' | 'blue'; diff --git a/docs/src/pages/css-in-js/basics/AdaptingStyledComponents.tsx b/docs/src/pages/css-in-js/basics/AdaptingStyledComponents.tsx index 6932a118c8e100..4fda410eda2421 100644 --- a/docs/src/pages/css-in-js/basics/AdaptingStyledComponents.tsx +++ b/docs/src/pages/css-in-js/basics/AdaptingStyledComponents.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { styled } from '@material-ui/core/styles'; import Button, { ButtonProps } from '@material-ui/core/Button'; -import { Omit } from '@material-ui/types'; interface MyButtonProps { color: 'red' | 'blue'; 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 f9ea1b8200265b..dafbba0449ab8f 100644 --- a/docs/src/pages/getting-started/supported-platforms/supported-platforms.md +++ b/docs/src/pages/getting-started/supported-platforms/supported-platforms.md @@ -47,4 +47,4 @@ Have a look at the older [versions](https://material-ui.com/versions/) for backw ## TypeScript -Material-UI requires a minimum version of TypeScript 3.2. +Material-UI requires a minimum version of TypeScript 3.5. diff --git a/docs/src/pages/guides/composition/ButtonRouter.tsx b/docs/src/pages/guides/composition/ButtonRouter.tsx index 0c99e31b5944c8..4d468adaf6a337 100644 --- a/docs/src/pages/guides/composition/ButtonRouter.tsx +++ b/docs/src/pages/guides/composition/ButtonRouter.tsx @@ -2,7 +2,6 @@ import * as React from 'react'; import { MemoryRouter as Router } from 'react-router'; import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom'; import Button from '@material-ui/core/Button'; -import { Omit } from '@material-ui/types'; const LinkBehavior = React.forwardRef>( (props, ref) => ( diff --git a/docs/src/pages/guides/composition/LinkRouter.tsx b/docs/src/pages/guides/composition/LinkRouter.tsx index c0e5ec364ecb95..5ebbc09aa534da 100644 --- a/docs/src/pages/guides/composition/LinkRouter.tsx +++ b/docs/src/pages/guides/composition/LinkRouter.tsx @@ -3,7 +3,6 @@ import * as React from 'react'; import { MemoryRouter as Router } from 'react-router'; import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom'; import Link from '@material-ui/core/Link'; -import { Omit } from '@material-ui/types'; const LinkBehavior = React.forwardRef>( (props, ref) => ( diff --git a/docs/src/pages/guides/composition/ListRouter.tsx b/docs/src/pages/guides/composition/ListRouter.tsx index 3d16559fa06d19..797dde21673913 100644 --- a/docs/src/pages/guides/composition/ListRouter.tsx +++ b/docs/src/pages/guides/composition/ListRouter.tsx @@ -11,7 +11,6 @@ import DraftsIcon from '@material-ui/icons/Drafts'; import Typography from '@material-ui/core/Typography'; import { Route, MemoryRouter } from 'react-router'; import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom'; -import { Omit } from '@material-ui/types'; interface ListItemLinkProps { icon?: React.ReactElement; diff --git a/docs/src/pages/guides/migration-v4/migration-v4.md b/docs/src/pages/guides/migration-v4/migration-v4.md index ae91e7a0cf988f..7c3fc5b098eb62 100644 --- a/docs/src/pages/guides/migration-v4/migration-v4.md +++ b/docs/src/pages/guides/migration-v4/migration-v4.md @@ -72,6 +72,13 @@ Support for non-ref-forwarding class components in the `component` prop or as im Otherwise check out the ["Caveat with refs" section in our composition guide](/guides/composition/#caveat-with-refs) to find out how to migrate. This change affects almost all components where you're using the `component` prop or passing `children` to components that require `children` to be elements (e.g. ``) +### Supported TypeScript version + +The minimum supported version of TypeScript was increased from v3.2 to v3.5. +We try to align with types released from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) (i.e. packages published on npm under the `@types` namespace). +We will not change the minimum supported version in a major version of Material-UI. +However, we generally recommend to not use a TypeScript version older than the [lowest supported version of DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped#older-versions-of-typescript-33-and-earlier) + ### Styled engine The styled engine used in v5 by default is [`emotion`](https://github.com/emotion-js/emotion). While migration from JSS to emotion, if you are using JSS style overrides for your components (for example overrides created by `makeStyles`), you need to take care of the CSS injection order. In order to do this, you need to have on the top of your application the `StylesProvider` with the `injectFirst` option. Here is an example of it: @@ -1266,3 +1273,12 @@ As the core components use emotion as a styled engine, the props used by emotion }, }); ``` + +### `@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](https://stackoverflow.com/a/57103940/1009797). + +```diff +-import { Omit } from '@material-ui/types'; ++import { DistributiveOmit } from '@material-ui/types'; +``` diff --git a/docs/src/pages/premium-themes/paperbase/Navigator.tsx b/docs/src/pages/premium-themes/paperbase/Navigator.tsx index 93a54b1150825a..f7a8767410848b 100644 --- a/docs/src/pages/premium-themes/paperbase/Navigator.tsx +++ b/docs/src/pages/premium-themes/paperbase/Navigator.tsx @@ -22,7 +22,6 @@ import SettingsInputComponentIcon from '@material-ui/icons/SettingsInputComponen import TimerIcon from '@material-ui/icons/Timer'; import SettingsIcon from '@material-ui/icons/Settings'; import PhonelinkSetupIcon from '@material-ui/icons/PhonelinkSetup'; -import { Omit } from '@material-ui/types'; const categories = [ { diff --git a/docs/src/pages/styles/basics/AdaptingHOC.tsx b/docs/src/pages/styles/basics/AdaptingHOC.tsx index 982fea08c59e11..f4f22fed8870a9 100644 --- a/docs/src/pages/styles/basics/AdaptingHOC.tsx +++ b/docs/src/pages/styles/basics/AdaptingHOC.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { withStyles, createStyles, WithStyles } from '@material-ui/core/styles'; import Button, { ButtonProps } from '@material-ui/core/Button'; -import { Omit } from '@material-ui/types'; const styles = createStyles({ root: { diff --git a/docs/src/pages/styles/basics/AdaptingHook.tsx b/docs/src/pages/styles/basics/AdaptingHook.tsx index f439dbcdb8737d..6b12985140d093 100644 --- a/docs/src/pages/styles/basics/AdaptingHook.tsx +++ b/docs/src/pages/styles/basics/AdaptingHook.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Button, { ButtonProps as MuiButtonProps } from '@material-ui/core/Button'; -import { Omit } from '@material-ui/types'; interface Props { color: 'red' | 'blue'; diff --git a/docs/src/pages/styles/basics/AdaptingStyledComponents.tsx b/docs/src/pages/styles/basics/AdaptingStyledComponents.tsx index 6932a118c8e100..4fda410eda2421 100644 --- a/docs/src/pages/styles/basics/AdaptingStyledComponents.tsx +++ b/docs/src/pages/styles/basics/AdaptingStyledComponents.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { styled } from '@material-ui/core/styles'; import Button, { ButtonProps } from '@material-ui/core/Button'; -import { Omit } from '@material-ui/types'; interface MyButtonProps { color: 'red' | 'blue'; diff --git a/packages/material-ui-lab/src/TabList/TabList.d.ts b/packages/material-ui-lab/src/TabList/TabList.d.ts index 895f2fe01293dc..acb3fe4a950b26 100644 --- a/packages/material-ui-lab/src/TabList/TabList.d.ts +++ b/packages/material-ui-lab/src/TabList/TabList.d.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import { TabsTypeMap } from '@material-ui/core/Tabs'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { OverridableComponent, OverrideProps } from '@material-ui/core/OverridableComponent'; export interface TabListTypeMap< @@ -12,7 +12,7 @@ export interface TabListTypeMap< * A list of `` elements. */ children?: React.ReactElement[]; - } & Omit; + } & DistributiveOmit; defaultComponent: D; } /** diff --git a/packages/material-ui-styles/src/makeStyles/makeStyles.d.ts b/packages/material-ui-styles/src/makeStyles/makeStyles.d.ts index b164e38cd7e3c4..63052cff7b4ecf 100644 --- a/packages/material-ui-styles/src/makeStyles/makeStyles.d.ts +++ b/packages/material-ui-styles/src/makeStyles/makeStyles.d.ts @@ -1,5 +1,4 @@ import { ClassNameMap, Styles, WithStylesOptions } from '@material-ui/styles/withStyles'; -import { Omit } from '@material-ui/types'; import { DefaultTheme } from '../defaultTheme'; export default function makeStyles< diff --git a/packages/material-ui-styles/src/styled/styled.d.ts b/packages/material-ui-styles/src/styled/styled.d.ts index da2edbb43df5eb..5cd622591bb5c5 100644 --- a/packages/material-ui-styles/src/styled/styled.d.ts +++ b/packages/material-ui-styles/src/styled/styled.d.ts @@ -1,4 +1,4 @@ -import { Omit, Overwrite } from '@material-ui/types'; +import { DistributiveOmit, Overwrite } from '@material-ui/types'; import { CreateCSSProperties, StyledComponentProps, @@ -22,7 +22,7 @@ export type ComponentCreator = < | ((props: { theme: Theme } & Props) => CreateCSSProperties), options?: WithStylesOptions ) => StyledComponent< - Omit< + DistributiveOmit< JSX.LibraryManagedAttributes>, 'classes' | 'className' > & diff --git a/packages/material-ui-styles/src/withTheme/withTheme.d.ts b/packages/material-ui-styles/src/withTheme/withTheme.d.ts index 0ae49c9c8de398..67b490228a3c24 100644 --- a/packages/material-ui-styles/src/withTheme/withTheme.d.ts +++ b/packages/material-ui-styles/src/withTheme/withTheme.d.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { ConsistentWith, Omit, PropInjector } from '@material-ui/types'; +import { ConsistentWith, DistributiveOmit, PropInjector } from '@material-ui/types'; import { DefaultTheme } from '../defaultTheme'; export interface WithThemeCreatorOption { @@ -30,7 +30,10 @@ export default function withTheme< >( component: C ): React.ComponentType< - Omit>, keyof WithTheme> & + DistributiveOmit< + JSX.LibraryManagedAttributes>, + keyof WithTheme + > & Partial> & ThemedComponentProps >; diff --git a/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.d.ts b/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.d.ts index 3207283b1d4615..2a30a79bcc0a65 100644 --- a/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.d.ts +++ b/packages/material-ui-system/src/styleFunctionSx/styleFunctionSx.d.ts @@ -55,6 +55,3 @@ export type SxProps = SystemStyleObject; // eslint-disable-next-line @typescript-eslint/naming-convention export default function unstable_styleFunctionSx(props: object): object; - -// utils -export type Omit = Pick>; diff --git a/packages/material-ui-types/index.d.ts b/packages/material-ui-types/index.d.ts index a26bcc28215454..6ecdd99908b71a 100644 --- a/packages/material-ui-types/index.d.ts +++ b/packages/material-ui-types/index.d.ts @@ -27,16 +27,17 @@ export type PropInjector = < >( component: C ) => React.JSXElementConstructor< - Omit>, keyof InjectedProps> & + DistributiveOmit>, keyof InjectedProps> & AdditionalProps >; /** * Remove properties `K` from `T`. + * Distributive for union types. * * @internal */ -export type Omit = T extends any ? Pick> : never; +export type DistributiveOmit = T extends any ? Omit : never; /** * Generate a set of string literal types with the given default record `T` and @@ -54,7 +55,7 @@ export type OverridableStringUnion = GenerateStringUnion = Omit & U; +export type Overwrite = DistributiveOmit & U; type GenerateStringUnion = Extract< { diff --git a/packages/material-ui-unstyled/src/OverridableComponent.d.ts b/packages/material-ui-unstyled/src/OverridableComponent.d.ts index 1ef05f04dc9d8a..5a212a03ef1b55 100644 --- a/packages/material-ui-unstyled/src/OverridableComponent.d.ts +++ b/packages/material-ui-unstyled/src/OverridableComponent.d.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; /** * A component whose root component can be controlled via a `component` prop. @@ -28,7 +28,7 @@ export type OverrideProps< C extends React.ElementType > = ( & BaseProps - & Omit, keyof BaseProps> + & DistributiveOmit, keyof BaseProps> ); /** @@ -37,7 +37,7 @@ export type OverrideProps< // prettier-ignore export type DefaultComponentProps = & BaseProps - & Omit, keyof BaseProps>; + & DistributiveOmit, keyof BaseProps>; /** * Props defined on the component (+ common material-ui props). diff --git a/packages/material-ui-utils/src/isMuiElement.d.ts b/packages/material-ui-utils/src/isMuiElement.d.ts index b0c8bd5d15391c..4f8ad123781409 100644 --- a/packages/material-ui-utils/src/isMuiElement.d.ts +++ b/packages/material-ui-utils/src/isMuiElement.d.ts @@ -1,4 +1,5 @@ import * as React from 'react'; +import { DistributiveOmit } from '@material-ui/types'; export type ClassNameMap = Record; @@ -15,7 +16,10 @@ export interface StyledComponentProps { * However, we don't declare classes on this type. * It is recommended to declare them manually with an interface so that each class can have a separate JSDOC. */ -export type StandardProps = Omit & +export type StandardProps = DistributiveOmit< + C, + 'classes' | Removals +> & // each component declares it's classes in a separate interface for proper JSDOC StyledComponentProps & { ref?: C extends { ref?: infer RefType } ? RefType : React.Ref; diff --git a/packages/material-ui/src/Backdrop/Backdrop.d.ts b/packages/material-ui/src/Backdrop/Backdrop.d.ts index 3fb4bdabe0fa9d..131d5ee958ab11 100644 --- a/packages/material-ui/src/Backdrop/Backdrop.d.ts +++ b/packages/material-ui/src/Backdrop/Backdrop.d.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import { SxProps } from '@material-ui/system'; -import { Omit, InternalStandardProps as StandardProps, Theme } from '..'; +import { InternalStandardProps as StandardProps, Theme } from '..'; import { FadeProps } from '../Fade'; import { TransitionProps } from '../transitions/transition'; diff --git a/packages/material-ui/src/Fade/Fade.d.ts b/packages/material-ui/src/Fade/Fade.d.ts index 5a33974732d820..39deb76d2efb06 100644 --- a/packages/material-ui/src/Fade/Fade.d.ts +++ b/packages/material-ui/src/Fade/Fade.d.ts @@ -1,5 +1,4 @@ import * as React from 'react'; -import { Omit } from '..'; import { TransitionProps } from '../transitions/transition'; export interface FadeProps extends Omit { diff --git a/packages/material-ui/src/GlobalStyles/GlobalStyles.d.ts b/packages/material-ui/src/GlobalStyles/GlobalStyles.d.ts index 0fa8bd0ffc9476..d8a286e869f595 100644 --- a/packages/material-ui/src/GlobalStyles/GlobalStyles.d.ts +++ b/packages/material-ui/src/GlobalStyles/GlobalStyles.d.ts @@ -1,5 +1,5 @@ import { GlobalStylesProps } from '@material-ui/styled-engine'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; /** * * API: @@ -7,5 +7,5 @@ import { Omit } from '@material-ui/types'; * - [Global API](https://material-ui.com/api/global/) */ export default function GlobalStyles( - props: Omit + props: DistributiveOmit ): React.ReactElement; diff --git a/packages/material-ui/src/Grow/Grow.d.ts b/packages/material-ui/src/Grow/Grow.d.ts index c26f0abae40a77..392fb60eb0bb0d 100644 --- a/packages/material-ui/src/Grow/Grow.d.ts +++ b/packages/material-ui/src/Grow/Grow.d.ts @@ -1,5 +1,4 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; import { TransitionProps } from '../transitions/transition'; export interface GrowProps extends Omit { diff --git a/packages/material-ui/src/Link/Link.d.ts b/packages/material-ui/src/Link/Link.d.ts index bdedf299888de3..a05b381d6382de 100644 --- a/packages/material-ui/src/Link/Link.d.ts +++ b/packages/material-ui/src/Link/Link.d.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { SxProps } from '@material-ui/system'; import { OverridableComponent, OverrideProps } from '../OverridableComponent'; import { Theme } from '../styles'; @@ -73,7 +73,7 @@ declare const Link: OverridableComponent; export type LinkClassKey = keyof NonNullable; export type LinkBaseProps = Omit, 'color'> & - Omit; + DistributiveOmit; export type LinkProps< D extends React.ElementType = LinkTypeMap['defaultComponent'], diff --git a/packages/material-ui/src/MenuItem/MenuItem.d.ts b/packages/material-ui/src/MenuItem/MenuItem.d.ts index 3ff08dc3bc5f45..f14c016eecc60f 100644 --- a/packages/material-ui/src/MenuItem/MenuItem.d.ts +++ b/packages/material-ui/src/MenuItem/MenuItem.d.ts @@ -1,4 +1,4 @@ -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { ListItemTypeMap, ListItemProps } from '../ListItem'; import { OverridableComponent, OverrideProps } from '../OverridableComponent'; import { ExtendButtonBase } from '../ButtonBase'; @@ -7,7 +7,7 @@ export type MenuItemClassKey = keyof NonNullable { props: P & - Omit['props'], 'children'> & { + DistributiveOmit['props'], 'children'> & { /** * The content of the component. */ diff --git a/packages/material-ui/src/OverridableComponent.d.ts b/packages/material-ui/src/OverridableComponent.d.ts index 7066d0a31d8262..6420048cccbcc3 100644 --- a/packages/material-ui/src/OverridableComponent.d.ts +++ b/packages/material-ui/src/OverridableComponent.d.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { StyledComponentProps } from './styles'; /** @@ -29,7 +29,7 @@ export type OverrideProps< C extends React.ElementType > = ( & BaseProps - & Omit, keyof BaseProps> + & DistributiveOmit, keyof BaseProps> ); /** @@ -38,7 +38,7 @@ export type OverrideProps< // prettier-ignore export type DefaultComponentProps = & BaseProps - & Omit, keyof BaseProps>; + & DistributiveOmit, keyof BaseProps>; /** * Props defined on the component (+ common material-ui props). diff --git a/packages/material-ui/src/Popper/Popper.d.ts b/packages/material-ui/src/Popper/Popper.d.ts index e51a8d39915bed..e84f99c7bd3931 100644 --- a/packages/material-ui/src/Popper/Popper.d.ts +++ b/packages/material-ui/src/Popper/Popper.d.ts @@ -1,6 +1,5 @@ import * as React from 'react'; import { Instance, VirtualElement, Options, OptionsGeneric } from '@popperjs/core'; -import { Omit } from '..'; import { PortalProps } from '../Portal'; export type PopperPlacementType = Options['placement']; diff --git a/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.d.ts b/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.d.ts index c7a741234a0a3c..d69926a602f6c7 100644 --- a/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.d.ts +++ b/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.d.ts @@ -1,5 +1,4 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; import { DrawerProps } from '../Drawer'; export interface SwipeableDrawerProps extends Omit { diff --git a/packages/material-ui/src/TablePagination/TablePagination.d.ts b/packages/material-ui/src/TablePagination/TablePagination.d.ts index 4793953e35714d..20ff5b3695448a 100644 --- a/packages/material-ui/src/TablePagination/TablePagination.d.ts +++ b/packages/material-ui/src/TablePagination/TablePagination.d.ts @@ -1,5 +1,4 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; import { OverridableComponent, OverrideProps } from '../OverridableComponent'; import { TablePaginationActionsProps } from './TablePaginationActions'; import { TableCellProps } from '../TableCell'; diff --git a/packages/material-ui/src/TextareaAutosize/TextareaAutosize.d.ts b/packages/material-ui/src/TextareaAutosize/TextareaAutosize.d.ts index 5bca7bf79edeeb..647eb282ff9869 100644 --- a/packages/material-ui/src/TextareaAutosize/TextareaAutosize.d.ts +++ b/packages/material-ui/src/TextareaAutosize/TextareaAutosize.d.ts @@ -1,5 +1,4 @@ import * as React from 'react'; -import { Omit } from '..'; export interface TextareaAutosizeProps extends Omit, 'children' | 'rows'> { diff --git a/packages/material-ui/src/index.d.ts b/packages/material-ui/src/index.d.ts index ddda43eabe80c3..0c2f46ebdeb87e 100644 --- a/packages/material-ui/src/index.d.ts +++ b/packages/material-ui/src/index.d.ts @@ -1,27 +1,20 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { StyledComponentProps } from './styles'; export { StyledComponentProps }; -/** - * @deprecated - * Import from `@material-ui/types` instead - * - * TODO: to remove in v5 - */ -export { Omit }; - /** * All standard components exposed by `material-ui` are `StyledComponents` with * certain `classes`, on which one can also set a top-level `className` and inline * `style`. * @deprecated will be removed in v5 for internal usage only */ -export type StandardProps = Omit< +export type StandardProps< C, - 'classes' | Removals -> & + ClassKey extends string, + Removals extends keyof C = never +> = DistributiveOmit & StyledComponentProps & { className?: string; ref?: C extends { ref?: infer RefType } ? RefType : React.Ref; @@ -35,7 +28,7 @@ export type StandardProps = Omit< +export type InternalStandardProps = DistributiveOmit< C, 'classes' | Removals > & diff --git a/packages/material-ui/src/styles/experimentalStyled.d.ts b/packages/material-ui/src/styles/experimentalStyled.d.ts index 8a5d2c1794ca27..8e4993269555e7 100644 --- a/packages/material-ui/src/styles/experimentalStyled.d.ts +++ b/packages/material-ui/src/styles/experimentalStyled.d.ts @@ -74,7 +74,6 @@ export type PropsOf< C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor > = JSX.LibraryManagedAttributes>; -export type Omit = T extends any ? Pick> : never; export type Overwrapped = Pick>; type JSXInEl = JSX.IntrinsicElements; diff --git a/packages/material-ui/src/styles/makeStyles.d.ts b/packages/material-ui/src/styles/makeStyles.d.ts index 1f8218efa0a9da..52ab0161420d8f 100644 --- a/packages/material-ui/src/styles/makeStyles.d.ts +++ b/packages/material-ui/src/styles/makeStyles.d.ts @@ -1,5 +1,5 @@ import { ClassNameMap, Styles, WithStylesOptions } from '@material-ui/styles/withStyles'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { Theme as DefaultTheme } from './createMuiTheme'; export default function makeStyles< @@ -8,7 +8,7 @@ export default function makeStyles< ClassKey extends string = string >( styles: Styles, - options?: Omit, 'withTheme'> + options?: DistributiveOmit, 'withTheme'> ): keyof Props extends never ? // `makeStyles` where the passed `styles` do not depend on props (props?: any) => ClassNameMap diff --git a/packages/material-ui/src/styles/styled.d.ts b/packages/material-ui/src/styles/styled.d.ts index 6ed2805893d232..b87d95e5112c59 100644 --- a/packages/material-ui/src/styles/styled.d.ts +++ b/packages/material-ui/src/styles/styled.d.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Omit } from '@material-ui/types'; +import { DistributiveOmit } from '@material-ui/types'; import { CreateCSSProperties, StyledComponentProps, @@ -23,12 +23,12 @@ export type ComponentCreator = < | ((props: { theme: Theme } & Props) => CreateCSSProperties), options?: WithStylesOptions ) => React.ComponentType< - Omit< + DistributiveOmit< JSX.LibraryManagedAttributes>, 'classes' | 'className' > & StyledComponentProps<'root'> & { className?: string } & (Props extends { theme: Theme } - ? Omit & { theme?: Theme } + ? DistributiveOmit & { theme?: Theme } : Props) >;