-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
TS Module augmentation for adding variants to components not working #28244
Comments
It doesn't look like this bug report has enough info for one of us to reproduce it. Please provide a CodeSandbox (https://material-ui.com/r/issue-template-next), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve |
I'm having the same issue when customizing or adding a variant for Buttons following the docs. |
@sveggiani Do you mind making a Code Sandbox showing the issue? |
@MarksCode I'll try when I have a moment. In the meantime I've found a workaround forcing the variant to
|
I think the issue here is that when a file with module augmentation doesn’t have Although, I’ve just quickly tested it in a CodeSandbox and TypeScript seems to recognize the new variant even if you replace In any case, developers that aren’t aware of this will benefit from a better documentation—even if it’ll be reiterating the obvious, which, I think, it won’t, because TypeScript’s documentation on module augmentation has never been clear in the first place. |
The correct way to go about this is shutting off automatic export, for example:
For example, take a look at how we are doing it for the |
It says in the docs here: https://next.material-ui.com/customization/theme-components/, adding a variant to a component when using typescript requires you add this:
However, this doesn't work. You'll still get an error in your
createTheme()
:In order to fix this you need to also add the line to your definitions file:
import '@mui/material/Button';
I'm not sure why this is the case but this should probably be added to the docs.
The text was updated successfully, but these errors were encountered: