From d12a999a32a3495dfe3c313409b24cfb1a489ee5 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Mon, 23 Mar 2020 19:06:14 +0100 Subject: [PATCH] [core] Enable module augmentation of CommonColors (#20212) --- packages/material-ui/src/styles/createPalette.d.ts | 8 ++++++-- packages/material-ui/src/styles/createPalette.spec.ts | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/material-ui/src/styles/createPalette.d.ts b/packages/material-ui/src/styles/createPalette.d.ts index 387c180c0bd677..1e8cf9893fdfbe 100644 --- a/packages/material-ui/src/styles/createPalette.d.ts +++ b/packages/material-ui/src/styles/createPalette.d.ts @@ -1,8 +1,12 @@ import { Color, PaletteType } from '..'; -import common from '../colors/common'; export {}; -type CommonColors = Record; +// use standalone interface over typeof colors/commons +// to enable module augmentation +export interface CommonColors { + black: string; + white: string; +} export type ColorPartial = Partial; diff --git a/packages/material-ui/src/styles/createPalette.spec.ts b/packages/material-ui/src/styles/createPalette.spec.ts index 3207b30e7be16b..45779b5112a974 100644 --- a/packages/material-ui/src/styles/createPalette.spec.ts +++ b/packages/material-ui/src/styles/createPalette.spec.ts @@ -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'; { @@ -22,3 +23,7 @@ import { palette.augmentColor(colorOrOption, 400); // $ExpectError const augmentedColor = palette.augmentColor(colorOrOption); } + +{ + const themeCommons: Theme['palette']['common'] = common; +}