Is there a way to make TypeScript honor tabs?

The indentation emitted by the compiler appears to be hardcoded.

So no, you can't configure it.


The workaround solution from [S-YOU] in typescript issues thread might be useful until typescript team allow to modify through tsconfig.json:

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

For those who just want to change the output to tab, you can patch typescript.js after you install.

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

if you want to change indentString to something you prefer change in those files the 2nd string to whatever you want.

Tags:

Typescript