![](/img/trans.png)
[英]Cannot find module './styles.scss' or its corresponding type declarations
[英]VSCode: Cannot find module 'antd' or its corresponding type declarations
我已经将 antd 安装到我的 typescript 项目中:
"antd": "^4.6.2",
它工作正常,我的项目使用 antd 组件(用于构建的 webpack)构建,但在 VSCode 中我没有输入,它给了我这个错误:
这是我的 tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"moduleResolution": "node",
}
}
我究竟做错了什么? Antd 应该包含它自己的类型,那么为什么 VSCode 不识别它呢?
该问题似乎是 VSCode 的已知问题: https : //github.com/Microsoft/TypeScript/issues/10346
可以通过手动添加来修复
/// <reference path="path/types.d.ts" />
然后做 F1 -> 重新加载窗口。
或者显然是通过安装 vscode typescript hero 插件。 我无法确认插件是否有效,因为我已经通过手动参考和重新加载进行了修复。
将 tsx 文件添加到 tsconfig.json:
{
...
"include": [
"./**/*.ts",
"./**/*.tsx"
],
...
}
F1 -> reload window
帮助了我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.