Skip to content

Commit

Permalink
[core] Enable module augmentation of CommonColors (#20212)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Mar 23, 2020
1 parent 5a794bd commit d12a999
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/material-ui/src/styles/createPalette.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Color, PaletteType } from '..';
import common from '../colors/common';

export {};
type CommonColors = Record<keyof typeof common, string>;
// use standalone interface over typeof colors/commons
// to enable module augmentation
export interface CommonColors {
black: string;
white: string;
}

export type ColorPartial = Partial<Color>;

Expand Down
7 changes: 6 additions & 1 deletion packages/material-ui/src/styles/createPalette.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Color } from '@material-ui/core';
import { blue } from '@material-ui/core/colors';
import { blue, common } from '@material-ui/core/colors';
import {
createPalette,
PaletteColorOptions,
SimplePaletteColorOptions,
Theme,
} from '@material-ui/core/styles';

{
Expand All @@ -22,3 +23,7 @@ import {
palette.augmentColor(colorOrOption, 400); // $ExpectError
const augmentedColor = palette.augmentColor(colorOrOption);
}

{
const themeCommons: Theme['palette']['common'] = common;
}

0 comments on commit d12a999

Please sign in to comment.