-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Description
Anytime I use the component prop on the Typography component I end up with type errors if I use the Intrinsic HTML props for that type of component. In this case, I am specifically referencing "htmlFor" when attempting to use a Typography component as a label.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Using the component prop on the Typography component triggers type errors when also using intrinsic HTML props that are unique to that component type.
Tested examples:
- label with htmlFor prop
- a with href prop
Expected Behavior 🤔
When using the component prop the Intrinsic HTML Props for the component are passed through to the component without type error.
Steps to Reproduce 🕹
https://codesandbox.io/s/purple-darkness-38cyt
Steps:
- Use the Typography Component
- Specify a component prop of 'a'
- Specify a 'href' prop
- See the type error
Context 🔦
I have seen some workarounds on other issues that involved creating an intermediary component but the dynamic nature of how we are applying these values would require an unknown number of intermediary components to be created during render and I don't want to unnecessarily bog down a production application based on a type issue. In this case we are using Typography components to style our form and filter labels in our app.
Your Environment 🌎
| Tech | Version |
|---|---|
| Material-UI | v4.6.1 |
| React | v16.12.0 |
| Browser | VSCode :P |
| TypeScript | v3.7.2 |
| etc. |
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"strictNullChecks": true,
"jsx": "preserve",
"strict": false
},
"exclude": [
"node_modules"
],
"include": [
"../global-lib/src/types/**/*.ts",
"src/next-env.d.ts",
"src/global.d.ts",
"src/styled.d.ts",
"src/**/*.ts",
"src/**/*.tsx"
]
}