admin管理员组文章数量:1315079
I'm using Vite (React+TypeScript template) and try to set up typed import CSS Modules. But I can't import any exactly class
test.module.css
.testCssClass {
color: greenyellow;
}
When I using it there are some problems.
I can import CSS module as CSSModuleClasses
but it doesn't have known keys for TypeScript
Module '"*.module.css"' has no exported member 'testCssClass'. Did you mean to use 'import testCssClass from "*.module.css"' instead? ts(2614)
I'have tried to use typescript-plugin-css-modules
in tsconfig.json
"compilerOptions": {
"plugins": [
{
"name": "typescript-plugin-css-modules",
}
]
}
But it doesn't help.
I'm using Vite (React+TypeScript template) and try to set up typed import CSS Modules. But I can't import any exactly class
test.module.css
.testCssClass {
color: greenyellow;
}
When I using it there are some problems.
I can import CSS module as CSSModuleClasses
but it doesn't have known keys for TypeScript
Module '"*.module.css"' has no exported member 'testCssClass'. Did you mean to use 'import testCssClass from "*.module.css"' instead? ts(2614)
I'have tried to use typescript-plugin-css-modules
in tsconfig.json
"compilerOptions": {
"plugins": [
{
"name": "typescript-plugin-css-modules",
}
]
}
But it doesn't help.
Share Improve this question asked Jan 30 at 10:43 Timur RuzievTimur Ruziev 655 bronze badges1 Answer
Reset to default 0Make sure the follow the Recommended usage mentioned in the typescript-plugin-css-modules readme.
Option 1: Set your Workspace's version of TypeScript.
- Open the VS Code command palette
- Enter
TypeScript: Select TypeScript Version...
- Choose your workspace version
Option 2: Set the plugin directly in your user/workspace settings (if you do not use any of the plugin options)
{
"typescript.tsserver.pluginPaths": ["typescript-plugin-css-modules"]
}
本文标签: How to type CSS Modules with TypeScript (Vite project)Stack Overflow
版权声明:本文标题:How to type CSS Modules with TypeScript (Vite project) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741971916a2407892.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论