有没有办法制作TypeScript荣誉标签?

Rom*_*ter 4 typescript

看来打字稿会忽略JavaScript文件的标签设置,并在生成的js文件中插入空格而不是标签。

有设置强制制表符而不是空格的设置吗?

使用VS 2013 Update 4的PS

Jou*_*ney 5

编译器发出的缩进似乎是硬编码的

所以不,您无法配置它。


小智 5

在 Typescript 团队允许通过 tsconfig.json 进行修改之前,Typescript 问题线程中 [S-YOU] 的解决方案可能会很有用:

https://github.com/Microsoft/TypeScript/issues/4042

对于那些只想将输出更改为选项卡的人,您可以在安装后修补 typescript.js。

sed -i 's/"    "/"\\t"/g' node_modules/typescript/lib/typescript.js

% grep "indentStrings =" node_modules/typescript -R

node_modules/typescript/lib/typescriptServices.js: var indentStrings = ["", "    "];
node_modules/typescript/lib/typescript.js: var indentStrings = ["", "\t"];
node_modules/typescript/lib/tsserverlibrary.js: var indentStrings = ["", "    "];
node_modules/typescript/lib/tsserver.js: var indentStrings = ["", "    "];
node_modules/typescript/lib/tsc.js: var indentStrings = ["", "    "];
Run Code Online (Sandbox Code Playgroud)

如果您想更改indentString为您喜欢的内容,请将这些文件中的第二个字符串更改为您想要的任何内容。