Open eugeneoshepkov opened 3 years ago
add file to your project, named react-css-module.d.ts.
declare namespace React {
interface Attributes {
styleName?: string | undefined;
}
interface HTMLAttributes<T> {
styleName?: string | undefined;
}
interface SVGAttributes<T> {
styleName?: string | undefined;
}
}
I have the same issue with "@types/react-css-modules": "^4.6.4",
@yinsang your solution doesn't work with
typescript 4.3.5
and react 17.0.2
Got Property 'styleName' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'
Maybe you have some thoughts how to fix that
This works for me(React@18.x)
// global.d.ts
declare namespace JSX {
interface IntrinsicAttributes {
styleName?: string;
}
}
declare namespace React {
interface Attributes {
styleName?: string;
}
interface HTMLAttributes
2. turn off this eslint rule
``` json
"react/no-unknown-property": "off"
There's a problem with extending
Attributes
andHTMLAttributes
interface withstyleName
with@types/react@^17
. It simply has no effect:"@types/react-css-modules": "^4.6.2",