Skip to content

Commit 40d1afb

Browse files
committed
test: Investigate removing IsEmptyInterface
1 parent f09c6d5 commit 40d1afb

File tree

4 files changed

+15
-53
lines changed

4 files changed

+15
-53
lines changed

__snapshots__/IsEmptyInterface

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
sources/IsEmptyInterface.test.ts(11,27): error TS2554: Expected 1 arguments, but got 0.
21
Files: 54
3-
Lines: 61530
4-
Nodes: 180467
5-
Identifiers: 62604
6-
Symbols: 104007
7-
Types: 36924
8-
Memory used: 135129K
9-
I/O read: 0.02s
2+
Lines: 61493
3+
Nodes: 180360
4+
Identifiers: 62571
5+
Symbols: 103235
6+
Types: 36774
7+
Memory used: 153131K
8+
I/O read: 0.01s
109
I/O write: 0.00s
11-
Parse time: 0.76s
12-
Bind time: 0.22s
13-
Check time: 3.14s
10+
Parse time: 0.66s
11+
Bind time: 0.28s
12+
Check time: 4.42s
1413
Emit time: 0.00s
15-
Total time: 4.12s
14+
Total time: 5.37s

vendor/@material-ui/styles/makeStyles/makeStyles.d.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,9 @@ import {
55
Styles,
66
WithStylesOptions,
77
} from '@material-ui/styles/withStyles';
8-
import { Omit, IsAny, Or, IsEmptyInterface } from '@material-ui/types';
8+
import { Omit } from '@material-ui/types';
99
import { DefaultTheme } from '../defaultTheme';
1010

11-
/**
12-
* @internal
13-
*
14-
* If a style callback is given with `theme => stylesOfTheme` then typescript
15-
* infers `Props` to `any`.
16-
* If a static object is given with { ...members } then typescript infers `Props`
17-
* to `{}`.
18-
*
19-
* So we require no props in `useStyles` if `Props` in `makeStyles(styles)` is
20-
* inferred to either `any` or `{}`
21-
*/
22-
export type StylesRequireProps<S> = Or<
23-
IsAny<PropsOfStyles<S>>,
24-
IsEmptyInterface<PropsOfStyles<S>>
25-
> extends true
26-
? false
27-
: true;
2811

2912
/**
3013
* @internal
@@ -33,9 +16,7 @@ export type StylesRequireProps<S> = Or<
3316
* from which the typechecker could infer a type so it falls back to `any`.
3417
* See the test cases for examples and implications of explicit `any` annotation
3518
*/
36-
export type StylesHook<S extends Styles<any, any>> = StylesRequireProps<S> extends false
37-
? (props?: any) => ClassNameMap<ClassKeyOfStyles<S>>
38-
: (props: PropsOfStyles<S>) => ClassNameMap<ClassKeyOfStyles<S>>;
19+
export type StylesHook<S extends Styles<any, any>> = (props?: PropsOfStyles<S>) => ClassNameMap<ClassKeyOfStyles<S>>
3920

4021
export default function makeStyles<
4122
Theme = DefaultTheme,

vendor/@material-ui/styles/withStyles/withStyles.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { PropInjector, CoerceEmptyInterface, IsEmptyInterface } from '@material-ui/types';
2+
import { PropInjector, CoerceEmptyInterface } from '@material-ui/types';
33
import * as CSS from 'csstype';
44
import * as JSS from 'jss';
55
import { DefaultTheme } from '../defaultTheme';
@@ -43,9 +43,7 @@ export interface CreateCSSProperties<Props extends object = {}>
4343
*/
4444
export type StyleRules<Props extends object = {}, ClassKey extends string = string> = Record<
4545
ClassKey,
46-
IsEmptyInterface<Props> extends true
47-
? CSSProperties | (() => CSSProperties)
48-
: CreateCSSProperties<Props> | ((props: Props) => CreateCSSProperties<Props>)
46+
CreateCSSProperties<Props> | ((props: Props) => CreateCSSProperties<Props>)
4947
>;
5048

5149
/**

vendor/@material-ui/types/index.d.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,3 @@ export type And<A, B, C = true> = A extends true
7171
: false
7272
: false
7373
: false;
74-
75-
/**
76-
* @internal
77-
*
78-
* check if a type is `{}`
79-
*
80-
* 1. false if the given type has any members
81-
* 2. false if the type is `object` which is the only other type with no members
82-
* {} is a top type so e.g. `string extends {}` but not `string extends object`
83-
* 3. false if the given type is `unknown`
84-
*/
85-
export type IsEmptyInterface<T> = And<
86-
keyof T extends never ? true : false,
87-
string extends T ? true : false,
88-
unknown extends T ? false : true
89-
>;

0 commit comments

Comments
 (0)