From e775b630ce31ed2945ac4e688a53da59c550c61f Mon Sep 17 00:00:00 2001 From: jxdp <32483798+jxdp@users.noreply.github.com> Date: Sun, 30 Jun 2024 16:15:02 +0100 Subject: [PATCH 1/2] [material-ui] Support `CssVarsTheme` in `responsiveFontSizes` return type (#42786) Signed-off-by: jxdp <32483798+jxdp@users.noreply.github.com> Co-authored-by: ZeeshanTamboli --- .../src/styles/responsiveFontSize.spec.ts | 14 ++++++++++++++ .../src/styles/responsiveFontSizes.d.ts | 7 +++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 packages/mui-material/src/styles/responsiveFontSize.spec.ts diff --git a/packages/mui-material/src/styles/responsiveFontSize.spec.ts b/packages/mui-material/src/styles/responsiveFontSize.spec.ts new file mode 100644 index 00000000000000..1eb6662ae2ef63 --- /dev/null +++ b/packages/mui-material/src/styles/responsiveFontSize.spec.ts @@ -0,0 +1,14 @@ +import { + responsiveFontSizes, + extendTheme, + createTheme, + Theme, + CssVarsTheme, +} from '@mui/material/styles'; +import { expectType } from '@mui/types'; + +const cssVarsTheme = responsiveFontSizes(extendTheme()); +expectType & CssVarsTheme, typeof cssVarsTheme>(cssVarsTheme); + +const theme = responsiveFontSizes(createTheme()); +expectType(theme); diff --git a/packages/mui-material/src/styles/responsiveFontSizes.d.ts b/packages/mui-material/src/styles/responsiveFontSizes.d.ts index 394419e5a8ef0f..ce66cf94eb1347 100644 --- a/packages/mui-material/src/styles/responsiveFontSizes.d.ts +++ b/packages/mui-material/src/styles/responsiveFontSizes.d.ts @@ -1,6 +1,5 @@ import { Breakpoint } from '@mui/system'; import { Typography } from './createTypography'; -import { Theme } from './createTheme'; export interface ResponsiveFontSizesOptions { breakpoints?: Breakpoint[]; @@ -9,7 +8,7 @@ export interface ResponsiveFontSizesOptions { variants?: Array; } -export default function responsiveFontSizes( - theme: Theme, +export default function responsiveFontSizes( + theme: T, options?: ResponsiveFontSizesOptions, -): Theme; +): T; From 76df1736bb1624f6772a1910d0f654f041eb8443 Mon Sep 17 00:00:00 2001 From: ZeeshanTamboli Date: Sun, 30 Jun 2024 22:59:49 +0530 Subject: [PATCH 2/2] fix test --- .../mui-material/src/styles/responsiveFontSize.spec.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/mui-material/src/styles/responsiveFontSize.spec.ts b/packages/mui-material/src/styles/responsiveFontSize.spec.ts index 1eb6662ae2ef63..d5fd3b16662fa7 100644 --- a/packages/mui-material/src/styles/responsiveFontSize.spec.ts +++ b/packages/mui-material/src/styles/responsiveFontSize.spec.ts @@ -1,14 +1,16 @@ import { responsiveFontSizes, - extendTheme, + experimental_extendTheme, createTheme, Theme, CssVarsTheme, } from '@mui/material/styles'; import { expectType } from '@mui/types'; -const cssVarsTheme = responsiveFontSizes(extendTheme()); -expectType & CssVarsTheme, typeof cssVarsTheme>(cssVarsTheme); +const cssVarsTheme = responsiveFontSizes(experimental_extendTheme()); +expectType & CssVarsTheme, typeof cssVarsTheme>( + cssVarsTheme, +); const theme = responsiveFontSizes(createTheme()); expectType(theme);