gpt4 book ai didi

reactjs - VSCode : Cannot find module 'antd' or its corresponding type declarations

转载 作者:行者123 更新时间:2023-12-03 14:13:45 68 4
gpt4 key购买 nike

我已经将antd安装到我的 typescript 项目中:

"antd": "^4.6.2",
它工作正常,我的项目使用antd组件(用于构建的webpack)构建,但是在VSCode内部,我没有输入内容,这给了我这个错误:
enter image description here
这是我的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插件来完成的。我无法确认插件是否正常工作,因为我已经通过手动引用和重新加载进行了修复。

关于reactjs - VSCode : Cannot find module 'antd' or its corresponding type declarations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63736300/

68 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com