From 139207fe213645c329d2b8a6294f542fcb638bd7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 7 Jan 2023 15:57:55 +0100 Subject: [PATCH] theme: explicit type imports from MUI v4 Signed-off-by: Patrik Oldsberg --- packages/theme/src/unified/UnifiedTheme.tsx | 6 +++--- .../src/unified/UnifiedThemeProvider.tsx | 2 +- packages/theme/src/unified/overrides.ts | 4 ++-- packages/theme/src/v4/baseTheme.ts | 7 ++++++- packages/theme/src/v4/types.ts | 21 +++++++++++-------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/theme/src/unified/UnifiedTheme.tsx b/packages/theme/src/unified/UnifiedTheme.tsx index dbb50c979e..bb31d88016 100644 --- a/packages/theme/src/unified/UnifiedTheme.tsx +++ b/packages/theme/src/unified/UnifiedTheme.tsx @@ -14,12 +14,12 @@ * limitations under the License. */ -import { +import { createTheme as createV4Theme } from '@material-ui/core/styles'; +import type { Theme as Mui4Theme, - createTheme as createV4Theme, ThemeOptions as ThemeOptionsV4, } from '@material-ui/core/styles'; -import { PaletteOptions as PaletteOptionsV4 } from '@material-ui/core/styles/createPalette'; +import type { PaletteOptions as PaletteOptionsV4 } from '@material-ui/core/styles/createPalette'; import { PaletteOptions as PaletteOptionsV5 } from '@mui/material/styles/createPalette'; import { adaptV4Theme, diff --git a/packages/theme/src/unified/UnifiedThemeProvider.tsx b/packages/theme/src/unified/UnifiedThemeProvider.tsx index 75fcc3c6ae..60f28bc353 100644 --- a/packages/theme/src/unified/UnifiedThemeProvider.tsx +++ b/packages/theme/src/unified/UnifiedThemeProvider.tsx @@ -17,9 +17,9 @@ import React, { ReactNode } from 'react'; import { StylesProvider as Mui4StylesProvider, - Theme as Mui4Theme, ThemeProvider as Mui4Provider, } from '@material-ui/core/styles'; +import type { Theme as Mui4Theme } from '@material-ui/core/styles'; import { StyledEngineProvider, Theme as Mui5Theme, diff --git a/packages/theme/src/unified/overrides.ts b/packages/theme/src/unified/overrides.ts index db1fb54c87..7417fccedc 100644 --- a/packages/theme/src/unified/overrides.ts +++ b/packages/theme/src/unified/overrides.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { Overrides } from '@material-ui/core/styles/overrides'; -import { ComponentsProps } from '@material-ui/core/styles/props'; +import type { Overrides } from '@material-ui/core/styles/overrides'; +import type { ComponentsProps } from '@material-ui/core/styles/props'; import { ComponentsOverrides, Theme, ThemeOptions } from '@mui/material/styles'; import { CSSProperties } from 'react'; diff --git a/packages/theme/src/v4/baseTheme.ts b/packages/theme/src/v4/baseTheme.ts index 411bcdf9a8..8143183ec0 100644 --- a/packages/theme/src/v4/baseTheme.ts +++ b/packages/theme/src/v4/baseTheme.ts @@ -16,7 +16,12 @@ import { Theme as Mui5Theme } from '@mui/material/styles'; import { createTheme as createMuiTheme } from '@material-ui/core/styles'; -import { GridProps, SwitchProps, Theme, ThemeOptions } from '@material-ui/core'; +import type { + GridProps, + SwitchProps, + Theme, + ThemeOptions, +} from '@material-ui/core'; import { Overrides } from '@material-ui/core/styles/overrides'; import { SimpleThemeOptions } from './types'; import { createBaseThemeOptions } from '../base'; diff --git a/packages/theme/src/v4/types.ts b/packages/theme/src/v4/types.ts index 24736e5d88..8bca5b8c3b 100644 --- a/packages/theme/src/v4/types.ts +++ b/packages/theme/src/v4/types.ts @@ -14,10 +14,13 @@ * limitations under the License. */ -import { Theme, ThemeOptions } from '@material-ui/core'; -import { - PaletteOptions, - Palette, +import type { + Theme as MuiTheme, + ThemeOptions as MuiThemeOptions, +} from '@material-ui/core'; +import type { + PaletteOptions as MuiPaletteOptions, + Palette as MuiPalette, } from '@material-ui/core/styles/createPalette'; import { BackstagePaletteAdditions, @@ -32,7 +35,7 @@ import { * @public * @deprecated This type is deprecated, the MUI Palette type is now always extended instead. */ -export type BackstagePalette = Palette & BackstagePaletteAdditions; +export type BackstagePalette = MuiPalette & BackstagePaletteAdditions; /** * The full Backstage palette options. @@ -40,7 +43,7 @@ export type BackstagePalette = Palette & BackstagePaletteAdditions; * @public * @deprecated This type is deprecated, the MUI PaletteOptions type is now always extended instead. */ -export type BackstagePaletteOptions = PaletteOptions & +export type BackstagePaletteOptions = MuiPaletteOptions & BackstagePaletteAdditions; /** @@ -55,7 +58,7 @@ export type BackstagePaletteOptions = PaletteOptions & * {@link BackstageTheme}. * */ -export interface BackstageThemeOptions extends ThemeOptions { +export interface BackstageThemeOptions extends MuiThemeOptions { palette: BackstagePaletteOptions; page: PageTheme; getPageTheme: (selector: PageThemeSelector) => PageTheme; @@ -67,7 +70,7 @@ export interface BackstageThemeOptions extends ThemeOptions { * @public * @deprecated This type is deprecated, the MUI Theme type is now always extended instead. */ -export interface BackstageTheme extends Theme { +export interface BackstageTheme extends MuiTheme { palette: BackstagePalette; page: PageTheme; getPageTheme: (selector: PageThemeSelector) => PageTheme; @@ -81,7 +84,7 @@ export interface BackstageTheme extends Theme { * @deprecated Use {@link BaseThemeOptionsInput} instead. */ export type SimpleThemeOptions = { - palette: PaletteOptions; + palette: MuiPaletteOptions; defaultPageTheme?: string; pageTheme?: Record; fontFamily?: string;