Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/material-ui-styles/src/withStyles/withStyles.d.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -83,9 +83,7 @@ export type ClassKeyOfStyles<StylesOrClassKey> = StylesOrClassKey extends string
/**
* infers the type of the props used in the styles
*/
export type PropsOfStyles<StylesType> = StylesType extends Styles<any, infer Props>
? CoerceEmptyInterface<Props>
: {};
export type PropsOfStyles<StylesType> = StylesType extends Styles<any, infer Props> ? Props : {};

/**
* infers the type of the theme used in the styles
Expand Down
5 changes: 0 additions & 5 deletions packages/material-ui-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ export type Overwrite<T, U> = Omit<T, keyof U> & U;
// https://stackoverflow.com/a/49928360/3406963 without generic branch types
export type IsAny<T> = 0 extends (1 & T) ? true : false;

/**
* Returns an empty object type if T is any, otherwise returns T
*/
export type CoerceEmptyInterface<T> = IsAny<T> extends true ? {} : T;

export type Or<A, B, C = false> = A extends true
? true
: B extends true
Expand Down
7 changes: 2 additions & 5 deletions packages/material-ui/src/styles/withStyles.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropInjector, CoerceEmptyInterface } from '@material-ui/types';
import { PropInjector } from '@material-ui/types';
import { Theme } from './createMuiTheme';
import {
CreateCSSProperties,
Expand Down Expand Up @@ -49,7 +49,4 @@ export default function withStyles<
>(
style: Styles<Theme, Props, ClassKey>,
options?: Options,
): PropInjector<
WithStyles<ClassKey, Options['withTheme']>,
StyledComponentProps<ClassKey> & CoerceEmptyInterface<Props>
>;
): PropInjector<WithStyles<ClassKey, Options['withTheme']>, StyledComponentProps<ClassKey> & Props>;