Skip to content

Commit 2fe0e5f

Browse files
committed
[core] Enable module augmentation of CommonColors
1 parent 8b32809 commit 2fe0e5f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/material-ui/src/styles/createPalette.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { Color, PaletteType } from '..';
2-
import common from '../colors/common';
32

43
export {};
5-
type CommonColors = Record<keyof typeof common, string>;
4+
// use standalone interface over typeof colors/commons
5+
// to enable module augmentation
6+
export interface CommonColors {
7+
black: string;
8+
white: string;
9+
}
610

711
export type ColorPartial = Partial<Color>;
812

packages/material-ui/src/styles/createPalette.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Color } from '@material-ui/core';
2-
import { blue } from '@material-ui/core/colors';
2+
import { blue, common } from '@material-ui/core/colors';
33
import {
44
createPalette,
55
PaletteColorOptions,
66
SimplePaletteColorOptions,
7+
Theme,
78
} from '@material-ui/core/styles';
89

910
{
@@ -22,3 +23,7 @@ import {
2223
palette.augmentColor(colorOrOption, 400); // $ExpectError
2324
const augmentedColor = palette.augmentColor(colorOrOption);
2425
}
26+
27+
{
28+
const themeCommons: Theme['palette']['common'] = common;
29+
}

0 commit comments

Comments
 (0)