[typescript] Typography in theme typed as `unknown`
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
At the moment the typography
key in the system’s theme
is typed as unknown
:
node_modules/@mui/system/createTheme/createTheme.d.ts
export interface ThemeOptions {
shape?: ShapeOptions;
breakpoints?: BreakpointsOptions;
direction?: Direction;
mixins?: unknown;
palette?: Record<string, any>;
shadows?: unknown;
spacing?: SpacingOptions;
transitions?: unknown;
components?: Record<string, any>;
typography?: unknown;
zIndex?: Record<string, number>;
}
Expected behavior 🤔
It should be typed to use TypographyVariants
and TypographyVariantOptions
or a @mui/system
alternative so that we get type safety when using theme.typography
like with @mui/material
Steps to reproduce 🕹
No response
Context 🔦
No response
Your environment 🌎
n/a
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:18 (9 by maintainers)
Top Results From Across the Web
[typescript] Typography in theme typed as unknown #30678
So, looks like we need to update the types for the typography inside the system's ThemeOptions and that should solve the issue, as...
Read more >MUI v5 - Extending Typography variant in TypeScript creates ...
const theme: Theme = createTheme({ typography: { h1Bold: ... To update Typography variant in Typescript, use the following code:
Read more >TypeScript - Theme UI
The Theme type represents all possible themes. It might be what you need when you're writing a library of reusable components or an...
Read more >TypeScript - Emotion
You can define a theme type by extending our type declarations via your own declarations file. emotion.d.ts. import '@emotion/react' declare module '@emotion ...
Read more >TypeScript - Material-UI
However type widening rears its ugly head once more if you try to make the styles depend on the theme: withStyles(({ palette, spacing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @mgoetz-nerdery . I was experiencing the same issue but I could workaround by the code below. In my case
theme.transitions
didn’t work because its type is ‘unknown’.Hi, I am running into this issue now using MUI 5.8.6, even when I try to use module augmentation. I get this error when I try module augmentation:
Has anyone found a workaround for this issue?