简体   繁体   English

防止VSCode / TypeScript自动更改整个项目的导入

[英]Prevent VSCode/TypeScript from Automatically Changing Imports for the Entire Project

This is the 3rd time that somewhere/somehow while I'm working VSCode/TypeScript has taken the initiative to go through the entire project and update the imports to use non-relative paths. 这是我第三次在某处/以某种方式工作时VSCode / TypeScript主动执行了整个项目并更新了导入以使用非相对路径。

Using non-relative paths like @app , @shared , @core , etc is great since it cleans up the imports, but when it occurs automatically project-wide instead of occurring only for new imports we get around 400 unstaged file changes, and need to work through reverting them to find the files that were being worked on since a commit like this would cause a bunch of merge conflicts. 使用@app@shared@core等非相对路径@app @shared ,因为它可以清理导入,但是当它在项目范围内自动发生而不是仅在新导入中发生时,我们会进行约400次未暂存的文件更改,因此需要通过还原它们来查找正在处理的文件,因为这样的提交会导致一堆合并冲突。

I thought maybe I'm hitting some sort of short cut key in VSCode, but I can't figure out if that's true. 我以为也许我在VSCode中敲了某种捷径,但是我不知道那是真的。 Is there a way to prevent the VSCode/TypeScript from automatically updating all the imports throughout a project? 有没有一种方法可以防止VSCode / TypeScript自动更新整个项目中的所有导入? We just want to use this feature for new imports during development as they are added, or manually update old imports, but not have them randomly updated project-wide. 我们只想在开发过程中为新导入添加新功能时使用此功能,或者手动更新旧的导入,但不要在项目范围内随机更新它们。

There are no VSCode packages installed that might perform this action. 没有安装可能执行此操作的VSCode软件包。

Prevent VSCode/TypeScript from Automatically Changing Imports for the Entire Project 防止VSCode / TypeScript自动更改整个项目的导入

The user setting is typescript.updateImportsOnFileMove.enabled and javascript.updateImportsOnFileMove.enabled . 用户设置为typescript.updateImportsOnFileMove.enabledjavascript.updateImportsOnFileMove.enabled Switch off with value "never" eg "never"值关闭,例如

"typescript.updateImportsOnFileMove.enabled": "never"

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

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