Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Enable module augmentation of CommonColors #20212

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}