Typescript typings issue with Button component
prop in combination with certain other props (like varient
)
#22452
Closed
2 tasks done
Labels
I am trying to follow along with https://material-ui.com/components/buttons/#third-party-routing-library and leveraging the nextjs-with-typescript example from material-ui. It appears that in some cases TypeScript has issues with certain combinations of properties.
Current Behavior 😯
I've made two changes from https://github.com/mui-org/material-ui/tree/master/examples/nextjs-with-typescript to demonstrate the expected behavior and the bug.
pages/about.tsx
, on lines 17-19, I've replaced the Link component with a Button using thecomponent={Link}
prop as mentioned in the third-party-routing-library guide. I have also added avariant="outlined"
prop to style the button, which causes TypeScript to throw this error:Expected Behavior 🤔
pages/index.tsx
I've made the same change but instead of usingvariant="outlined"
, I've usedcolor="secondary"
and everything works as expected.Steps to Reproduce 🕹
Refer to this codesandbox for a reproduction of the bug: https://codesandbox.io/s/bold-water-9xdld?file=/pages/about.tsx
Context 🔦
I'm guessing this is a silly TypeScript issue (I'm still learning and appreciate the value but also get frustrated by silly things like this). I want to be able to use the full power of buttons and not just certain combinations so this is blocking me. Other workarounds I've tried have various drawbacks as well..
Your Environment 🌎
The text was updated successfully, but these errors were encountered: