From bb3a8aafd9a9c590f26db9b6002c9154b1f4e30b Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Wed, 15 Jan 2020 20:31:28 +0100 Subject: [PATCH] [types] Remove CoerceEmptyInterface (#19259) --- packages/material-ui-styles/src/withStyles/withStyles.d.ts | 6 ++---- packages/material-ui-types/index.d.ts | 5 ----- packages/material-ui/src/styles/withStyles.d.ts | 7 ++----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/material-ui-styles/src/withStyles/withStyles.d.ts b/packages/material-ui-styles/src/withStyles/withStyles.d.ts index 1df7d1cfbf74fe..b3610bd3857969 100644 --- a/packages/material-ui-styles/src/withStyles/withStyles.d.ts +++ b/packages/material-ui-styles/src/withStyles/withStyles.d.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { PropInjector, CoerceEmptyInterface, IsEmptyInterface } from '@material-ui/types'; +import { PropInjector, IsEmptyInterface } from '@material-ui/types'; import * as CSS from 'csstype'; import * as JSS from 'jss'; import { DefaultTheme } from '../defaultTheme'; @@ -83,9 +83,7 @@ export type ClassKeyOfStyles = StylesOrClassKey extends string /** * infers the type of the props used in the styles */ -export type PropsOfStyles = StylesType extends Styles - ? CoerceEmptyInterface - : {}; +export type PropsOfStyles = StylesType extends Styles ? Props : {}; /** * infers the type of the theme used in the styles diff --git a/packages/material-ui-types/index.d.ts b/packages/material-ui-types/index.d.ts index 1e0957d8ba1852..4dea0a07d4d61f 100644 --- a/packages/material-ui-types/index.d.ts +++ b/packages/material-ui-types/index.d.ts @@ -51,11 +51,6 @@ export type Overwrite = Omit & U; // https://stackoverflow.com/a/49928360/3406963 without generic branch types export type IsAny = 0 extends (1 & T) ? true : false; -/** - * Returns an empty object type if T is any, otherwise returns T - */ -export type CoerceEmptyInterface = IsAny extends true ? {} : T; - export type Or = A extends true ? true : B extends true diff --git a/packages/material-ui/src/styles/withStyles.d.ts b/packages/material-ui/src/styles/withStyles.d.ts index 81784bd62a372e..af3dac2f00e73a 100644 --- a/packages/material-ui/src/styles/withStyles.d.ts +++ b/packages/material-ui/src/styles/withStyles.d.ts @@ -1,4 +1,4 @@ -import { PropInjector, CoerceEmptyInterface } from '@material-ui/types'; +import { PropInjector } from '@material-ui/types'; import { Theme } from './createMuiTheme'; import { CreateCSSProperties, @@ -49,7 +49,4 @@ export default function withStyles< >( style: Styles, options?: Options, -): PropInjector< - WithStyles, - StyledComponentProps & CoerceEmptyInterface ->; +): PropInjector, StyledComponentProps & Props>;