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

Is there a way to make TypeScript honor tabs?

似乎 typescript 忽略了 JavaScript 文件的制表符设置,并在生成的 js 文件中插入空格而不是制表符。

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

P.S。使用 VS 2013 更新 4

编译器发出的缩进 appears to be hardcoded

所以不,你不能配置它。

typescript 问题线程中来自 [S-YOU] 的解决方法可能有用,直到 typescript 团队允许通过 tsconfig.json 进行修改:

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 = ["", "    "];

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