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

查看:78
本文介绍了防止 VSCode/TypeScript 自动更改整个项目的导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 VSCode/TypeScript 第 3 次在某个地方/以某种方式主动检查整个项目并更新导入以使用非相对路径.

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.

使用诸如 @app@shared@core 等非相对路径非常棒,因为它可以清理导入,但是当它在项目范围内自动发生而不是仅发生在新导入时,我们会得到大约 400 个未暂存的文件更改,并且需要通过还原它们来查找正在处理的文件,因为这样的提交会导致一堆合并冲突.

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.

我想也许我在 VSCode 中按下了某种快捷键,但我不知道这是否属实.有没有办法阻止 VSCode/TypeScript 自动更新整个项目中的所有导入?我们只想在开发过程中在添加新导入时使用此功能,或者手动更新旧导入,但不会在项目范围内随机更新它们.

I thought maybe I'm hitting some sort of short cut key in VSCode, but I can't figure out if that's true. Is there a way to prevent the VSCode/TypeScript from automatically updating all the imports throughout a project? 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.

没有安装可能执行此操作的 VSCode 包.

There are no VSCode packages installed that might perform this action.

推荐答案

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

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

用户设置为 typescript.updateImportsOnFileMove.enabledjavascript.updateImportsOnFileMove.enabled.关闭值 "never" 例如

The user setting is typescript.updateImportsOnFileMove.enabled and javascript.updateImportsOnFileMove.enabled. Switch off with value "never" e.g.

"typescript.updateImportsOnFileMove.enabled": "never"

这篇关于防止 VSCode/TypeScript 自动更改整个项目的导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆