Skip to content

Commit

Permalink
feat: Remove CoerceEmptyInterface (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jan 15, 2020
1 parent f09c6d5 commit e1ae432
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 36 deletions.
20 changes: 10 additions & 10 deletions __snapshots__/IsEmptyInterface
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
sources/IsEmptyInterface.test.ts(11,27): error TS2554: Expected 1 arguments, but got 0.
Files: 54
Lines: 61530
Nodes: 180467
Identifiers: 62604
Symbols: 104007
Types: 36924
Memory used: 135129K
Lines: 61523
Nodes: 180439
Identifiers: 62593
Symbols: 104001
Types: 36907
Memory used: 133717K
I/O read: 0.02s
I/O write: 0.00s
Parse time: 0.76s
Bind time: 0.22s
Check time: 3.14s
Parse time: 0.68s
Bind time: 0.76s
Check time: 3.13s
Emit time: 0.00s
Total time: 4.12s
Total time: 4.57s
12 changes: 6 additions & 6 deletions vendor/@material-ui/core/styles/styled.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Omit, IsAny, CoerceEmptyInterface } from '@material-ui/types';
import { Omit } from '@material-ui/types';
import {
CreateCSSProperties,
StyledComponentProps,
Expand All @@ -16,20 +16,20 @@ import * as React from 'react';
*/
export type ComponentCreator<Component extends React.ElementType> = <
Theme = DefaultTheme,
Props extends {} = any
Props extends {} = {}
>(
styles:
| CreateCSSProperties<Props>
| ((props: { theme: Theme } & CoerceEmptyInterface<Props>) => CreateCSSProperties<Props>),
| ((props: { theme: Theme } & Props) => CreateCSSProperties<Props>),
options?: WithStylesOptions<Theme>,
) => React.ComponentType<
Omit<
JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
'classes' | 'className'
> &
StyledComponentProps<'root'> & { className?: string } & CoerceEmptyInterface<
Props extends { theme: Theme } ? Omit<Props, 'theme'> & { theme?: Theme } : Props
>
StyledComponentProps<'root'> & { className?: string } & (Props extends { theme: Theme }
? Omit<Props, 'theme'> & { theme?: Theme }
: Props)
>;

export interface StyledProps {
Expand Down
7 changes: 2 additions & 5 deletions vendor/@material-ui/core/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>;
12 changes: 6 additions & 6 deletions vendor/@material-ui/styles/styled/styled.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Omit, IsAny, CoerceEmptyInterface } from '@material-ui/types';
import { Omit } from '@material-ui/types';
import {
CreateCSSProperties,
StyledComponentProps,
Expand All @@ -12,20 +12,20 @@ import { DefaultTheme } from '../defaultTheme';
*/
export type ComponentCreator<Component extends React.ElementType> = <
Theme = DefaultTheme,
Props extends {} = any
Props extends {} = {}
>(
styles:
| CreateCSSProperties<Props>
| ((props: { theme: Theme } & CoerceEmptyInterface<Props>) => CreateCSSProperties<Props>),
| ((props: { theme: Theme } & Props) => CreateCSSProperties<Props>),
options?: WithStylesOptions<Theme>,
) => React.ComponentType<
Omit<
JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
'classes' | 'className'
> &
StyledComponentProps<'root'> & { className?: string } & CoerceEmptyInterface<
Props extends { theme: Theme } ? Omit<Props, 'theme'> & { theme?: Theme } : Props
>
StyledComponentProps<'root'> & { className?: string } & (Props extends { theme: Theme }
? Omit<Props, 'theme'> & { theme?: Theme }
: Props)
>;

export interface StyledProps {
Expand Down
6 changes: 2 additions & 4 deletions vendor/@material-ui/styles/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 vendor/@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

0 comments on commit e1ae432

Please sign in to comment.