[使用VS Code和Typescript或JavaScript时,VS Code建议自动导入。但是,当自动插入导入时,它将在行尾添加分号。我不要这个分号。另外,它在我的tslint中是这样配置的。
无论如何告诉VS Code不要插入该分号?
目前,对于VSCode 1.30.2,TypeScript 3.3,目前无法执行此操作。
您可以在此处查看功能请求:https://github.com/Microsoft/TypeScript/issues/19882
但是此功能可能出现在TypeScript 3.4中,因为@RyanCavanaugh将里程碑更新为3.4
同时,我使用semi-standard
样式。
而且,由于对齐方式混乱,纯standard
样式在VSCode中也无法正常工作:
function foo() {
const x = {}
;['a'].map(x => console.log(x)) // <-- alignment is bad
}
VS代码1.38尝试将infer if semicolons should be used用于JavaScript和TypeScript中的自动导入和重构。
使用VS Code 1.39和TypeScript 3.7+,也可以显式set是否应使用分号:
"javascrriptscript.format.semicolons": "remove",
"typescript.format.semicolons": "remove"
((请注意,在发布VS Code 1.40之前,可能需要安装this extension才能在VS Code中实际启用TypeScript 3.7)