Multiple declare module '@mui/material/Button' don't work
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
The current advise is to use the following code
declare module '@mui/material/Button' {
interface ButtonPropsVariantOverrides {
pill2: true
}
}
This works if they are in the same file, you can see that pill2 is recognized:

If I move the second declaration to another file it isn't picked up anymore:

If I replace the import paths with '@mui/material/Button/Button' it works as expected:

Expected behavior 🤔
The documentation should probably advise the following code:
declare module '@mui/material/Button/Button' {
interface ButtonPropsVariantOverrides {
pill2: true
}
}
Steps to reproduce 🕹
See screenshots in Current behavior.
Context 🔦
We have some base declarations we want to make and allow 'implementors' add new declarations.
Your environment 🌎
`npx @mui/envinfo`
System:
OS: macOS 12.2.1
Binaries:
Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
Yarn: 1.19.1 - ~/.nvm/versions/node/v14.19.0/bin/yarn
npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm
Browsers:
Chrome: 99.0.4844.51
Edge: 99.0.1150.36
Firefox: Not Found
Safari: 15.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using two separate TypeScript declaration files for '@mui/material/Button', then compare that result with the '@mui/material/Button/Button' path shown in the report. Start by examining the module-augmentation guidance referenced in the issue; done means the documented declaration path works when declarations are split across files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100