简体   繁体   English

TypeScript 类型定义 IntelliSense 错误

[英]TypeScript type definitions IntelliSense errors

With Visual Studio 2022, I have a lot of IntelliSense errors in the error list window about type definitions of the node_modules folder.使用 Visual Studio 2022,关于 node_modules 文件夹的类型定义的错误列表 window 中有很多 IntelliSense 错误。
In my tsconfig.json file, I excluded the node_modules folder: "exclude": ["node_modules"] .在我的 tsconfig.json 文件中,我排除了 node_modules 文件夹: "exclude": ["node_modules"]
In my csproj, I added the line <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> .在我的 csproj 中,我添加了<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>行。
But nothing works, I didn't succeed in removing these errors.但是没有任何效果,我没有成功消除这些错误。

在此处输入图像描述

After lots of trial and error, I've gotten "exclude": ["./node_modules/**/*.*"] to successfully ignore node_modules.经过大量的试验和错误,我得到了"exclude": ["./node_modules/**/*.*"]成功忽略 node_modules。 It didn't take effect until I restarted Visual Studio.直到我重新启动 Visual Studio 才生效。

It will depend on your tsconfig - can you share your setup?这将取决于您的 tsconfig - 您可以分享您的设置吗? Will want to exclude your dist file as well as your node_modules (and if you want tests/spec files).会想要排除你的 dist 文件以及你的 node_modules (如果你想要测试/规范文件)。

"exclude": ["node_modules", "**/*.spec.ts", "dist"]

Webpack has not exported member compilation was the error i saw first - what are you importing with that? Webpack has not export member compilation 是我首先看到的错误 - 你在导入什么? Docs here for webpack and typescript. webpack 和 typescript 的文档在这里

Wondering if your types are discoverable, could try adding below to tsconfig想知道您的类型是否可发现,可以尝试在下面添加到 tsconfig

"typeRoots": [
   "./node_modules/@types"
]

The problem is fixed in Visual Studio 2022 17.3.该问题已在 Visual Studio 2022 17.3 中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM