It seems that typescript ignores tab settings for JavaScript files and inserts spaces instead of tabs in the generated js file.
Is there a setting to force tabs instead of spaces?
P.S. Using VS 2013 Update 4
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.
Old issue but since this is still relevant, I find that adding && prettier --write ./dist
to your build
command would be a better option, since TypeScript output doesn't seem to be well-formatted even if you patch the TypeScript library files. Plus, when you deploy to Heroku, the deployment environment handles package installation and build; so this gives you control over the output even then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With