我正在使用babel-plugin-react-css-modules
. 它将styleName
属性添加到 HTML 元素。Typescript 无法识别此属性。我很确定我需要扩展一些东西,但我尝试过的任何东西都没有奏效。
我曾尝试Element
在“.d.ts”文件中声明一个来进行声明合并,但我一定是做错了什么。
interface Element {
styleName: string;
}
export const Wrapper: React.FC<IWrapperProps> = ({ children, style }) => (
<div styleName="wrapper" style={style}>
{children}
</div>
);
更新: