-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[typescript] Typography in theme typed as unknown
#30678
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
Comments
On top of this, i am unable to access |
Also |
What do you mean you can't access |
unknown
unknown
Can you provide a codesandbox that shows the error and what you want to achieve clearly? You can fork this template (https://material-ui.com/r/issue-template-latest). |
Hi @hbjORbj, please see this sandbox: https://codesandbox.io/s/loving-violet-nguoc?file=/src/Demo.tsx Notice the type failing on fontSize. This is also true for custom theme properties as well as the other properties that are typed 'unknown' |
Hi, Please check out https://codesandbox.io/s/lucid-agnesi-9gt0d?file=/src/Demo.tsx |
👋 Thanks for using MUI Core! We use GitHub issues exclusively as a bug and feature requests tracker, however, For support, please check out https://mui.com/getting-started/support/. Thanks! If you have a question on StackOverflow, you are welcome to link to it here, it might help others. |
@hbjORbj Is this the wrong repo to post system issues? As far as I'm aware |
@mnajdova has helped in the past with @mui/system issues on this repo. |
@Nicktho I agree we should improve the typings on these utils. Especially as we envision those would be used in different design systems. We could either, add typings that could be changed by module augmentation, or provide generics. |
@siriwatknp from Joy's standpoint, what would work better? |
Thanks for reopening @mnajdova! We ended up extending |
We need to be clear on what package are we talking about but from the MUI system perspective, the declare module "@mui/system" {
interface TypographyScaleOverrides {
body: CSSObject;
...your choice
}
}
I lean toward module augmentation because:
|
So, looks like we need to update the types for the typography inside the system's |
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? |
cc @siriwatknp? |
Please share the code snippet or a reproducible sandbox. |
Hi @mgoetz-nerdery . ...
transition: (theme.transitions as any).create('width'),
... |
Please use - import { styled } from '@mui/system';
+ import { styled } from '@mui/material/styles'; // or '@mui/material' |
We could work on this in v6 according to #30988. |
- unfortunately the MUI/system lib is not configured for overriding some theme property types, like 'palette' & 'typography' - mui/material-ui#30678 - the styles property is added via module augmentation, allows for a type safe usage of theme in child components.
Duplicates
Latest version
Current behavior 😯
At the moment the
typography
key in the system'stheme
is typed asunknown
:node_modules/@mui/system/createTheme/createTheme.d.ts
Expected behavior 🤔
It should be typed to use
TypographyVariants
andTypographyVariantOptions
or a@mui/system
alternative so that we get type safety when usingtheme.typography
like with@mui/material
Steps to reproduce 🕹
No response
Context 🔦
No response
Your environment 🌎
n/a
The text was updated successfully, but these errors were encountered: