Skip to content

Commit

Permalink
[createSpacing] Narrow return type (#14745)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Mar 5, 2019
1 parent d4425c6 commit 8304d9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions packages/material-ui/src/styles/createSpacing.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/* tslint:disable:unified-signatures */

export type SpacingArgument = number | string;
export type SpacingReturnType = number | string;

export interface Spacing {
(value1: SpacingArgument): SpacingReturnType;
(value1: SpacingArgument, value2: SpacingArgument): SpacingReturnType;
(value1: SpacingArgument, value2: SpacingArgument, value3: SpacingArgument): SpacingReturnType;
(value1: SpacingArgument): number;
(value1: SpacingArgument, value2: SpacingArgument): string;
(value1: SpacingArgument, value2: SpacingArgument, value3: SpacingArgument): string;
(
value1: SpacingArgument,
value2: SpacingArgument,
value3: SpacingArgument,
value4: SpacingArgument,
): SpacingReturnType;
): string;
}

export type SpacingOptions = number | Spacing;
Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui/test/typescript/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ const theme2 = createMuiTheme({
},
});

const t1 = createMuiTheme().spacing(1);
const t2 = createMuiTheme().spacing(1, 2);
const t3 = createMuiTheme().spacing(1, 2, 3);
const t4 = createMuiTheme().spacing(1, 2, 3, 4);
const t1: number = createMuiTheme().spacing(1);
const t2: string = createMuiTheme().spacing(1, 2);
const t3: string = createMuiTheme().spacing(1, 2, 3);
const t4: string = createMuiTheme().spacing(1, 2, 3, 4);
// $ExpectError
const t5 = createMuiTheme().spacing(1, 2, 3, 4, 5);

Expand Down

0 comments on commit 8304d9d

Please sign in to comment.