[英]visual studio settings for typescript intellisense and TS2307 (TS) Cannot find module Miscellaneous
The command npm run build
successfully build the package and the app runs in browser just fine.命令
npm run build
成功构建包,应用程序在浏览器中运行得很好。 But the VS2019 keeps complaining with Error TS2307 (TS) Cannot find module '...'.但是 VS2019 一直抱怨错误 TS2307 (TS) 找不到模块 '...'。 Miscellaneous .
杂。
Is there a setting in the IDE where some things should be changed to make the the VS as happy as the npm? IDE 中是否有设置应该更改某些内容以使 VS 与 npm 一样快乐?
EDIT Restart of the IDE resolved one line but not the other编辑重新启动 IDE 解决了一行,但没有解决另一行
The answer is yes.答案是肯定的。 There are settings in the project that might make the experience somewhat inconsistent.
项目中有一些设置可能会使体验有些不一致。
VS uses project file ( .csproj
) and IDE default settings to configure typescript intellisence when the tsconfig.json
file is not part of the project.当
tsconfig.json
文件不是项目的一部分时,VS 使用项目文件 ( .csproj
) 和 IDE 默认设置来配置打字稿智能。 The npm run build
command (or similar CLI approach) on the other hand uses the tsconfig.json
all the time.另一方面,
npm run build
命令(或类似的 CLI 方法)一直使用tsconfig.json
。 This may lead to mixed experience.这可能会导致混合体验。 Indeed VS will show false hints and errors if particular settings differ in
.csproj
and in tsconfig.json
.如果
.csproj
和tsconfig.json
特定设置不同,VS 确实会显示错误提示和错误。
Make sure tsconfig.json relates to the build process as Content (rather than None ) yet never copied to the output directory.确保 tsconfig.json 作为Content (而不是None )与构建过程相关,但从未复制到输出目录。 This way you force the IDE to detect your settings and use them.
这样您就可以强制 IDE 检测您的设置并使用它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.