[英]How to change VSCode quick fix generated imports for TypeScript to use relative paths?
I use VSCode (1.17.2 at time of writing) with TypeScript (2.5.2). 我在使用TypeScript(2.5.2)时使用VSCode(编写时为1.17.2)。 When I start to use a class in .ts file that is not yet imported, there is error and the class name i underlined with possibility to use Quick Fix bulp to import it.
当我开始使用尚未导入的.ts文件中的类时,会出现错误,并且我强调了类名,可以使用Quick Fix bulp导入它。 But it uses absolute path (actually relative to project root) to the file, eg
但它使用绝对路径(实际上相对于项目根目录)到文件,例如
import { FormattedValue } from 'src/app/entities/formattedValue';
It works but when I create modules that can be just copied to different projects (having different project's folder structure) I need the paths to be relative. 它可以工作但是当我创建可以复制到不同项目的模块(具有不同项目的文件夹结构)时,我需要路径是相对的。 So when I start using eg
FormattedValue
in file src/app/entities/xy.ts
, the generated import should look like 所以当我开始在文件
src/app/entities/xy.ts
使用例如FormattedValue
时,生成的导入应该看起来像
import { IFormattedValue } from './formattedValue';
Is there a way how to setup VSCode to use relative paths in quick fix generted imports? 有没有办法如何设置VSCode在快速修复基因导入中使用相对路径?
在vscode设置中,添加以下设置:
"typescript.preferences.importModuleSpecifier": "relative"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.