简体   繁体   English

打字稿智能感知和 TS2307 (TS) 的 Visual Studio 设置找不到模块杂项

[英]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 . 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? IDE 中是否有设置应该更改某些内容以使 VS 与 npm 一样快乐?

EDIT Restart of the IDE resolved one line but not the other编辑重新启动 IDE 解决了一行,但没有解决另一行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 .如果.csprojtsconfig.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 检测您的设置并使用它们。

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

在此处输入图片说明

暂无
暂无

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

相关问题 错误TS2307:找不到模块'反应' - error TS2307: Cannot find module 'react' 将 PNG/SVG 导入 React - TS2307:找不到模块 - Importing PNGs/SVGs into React - TS2307: Cannot find module Typescript React / NestJS 应用程序失败 @Heroku 构建 - “错误 TS2307:找不到模块” - Typescript React / NestJS app fails @Heroku build - “error TS2307: Cannot find module” TS2307:找不到模块“./tables.module.css”或其相应的类型声明 - TS2307: Cannot find module './tables.module.css' or its corresponding type declarations 在 React 中找不到模块 TS2307 - Can't find module TS2307 in React 导入空类时出错,错误TS2307:找不到模块“菜单” - Error importing empty class, error TS2307: Cannot find module 'menu' TS2307:找不到模块 '_rc-trigger@5.2.0@rc-trigger' 或其对应的类型声明 - TS2307: Cannot find module '_rc-trigger@5.2.0@rc-trigger' or its corresponding type declarations TS2307 错误:找不到模块“../constants”或其相应的类型声明 - TS2307 Error: Cannot find module '../constants' or its corresponding type declarations React,Storybook - TS2307:找不到模块“按钮”或其相应的类型声明 CAN SB RESOLVE? - React,Storybook - TS2307: Cannot find module 'Button' or its corresponding type declarations CAN SB RESOLVE? 由于“找不到模块'环境'。 TS2307”,craco 导致纱线构建失败 - craco causes yarn build to fail due to "Cannot find module 'environment'. TS2307"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM