简体   繁体   中英

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. But the VS2019 keeps complaining with Error TS2307 (TS) Cannot find module '...'. Miscellaneous . tsconfig.json 工作正常

Is there a setting in the IDE where some things should be changed to make the the VS as happy as the npm?

EDIT Restart of the IDE resolved one line but not the otherIDE 还是不开心

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. The npm run build command (or similar CLI approach) on the other hand uses the tsconfig.json all the time. This may lead to mixed experience. Indeed VS will show false hints and errors if particular settings differ in .csproj and in tsconfig.json .

Make sure tsconfig.json relates to the build process as Content (rather than None ) yet never copied to the output directory. This way you force the IDE to detect your settings and use them.

tsconfig.json 必须是项目的一部分

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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