-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsconfig.json compiler option: indent #4042
Comments
Of course, if my editor displayed tabs in a different width, this would look even more horrible. |
This seems like a setting better suited to .editorconfig? |
@danquirk I use EditorConfig religiously and belong to the organization; however, this is definitely a compiler option. The only way I could see EditorConfig coming into the mix is if the compiler actually ran each file path against EditorConfig to see which settings should be applied per file. I really don't want to incur the performance hit of doing this in the TypeScript compiler, so I feel this is much better suited as a compiler option. Besides, your source files are likely all the same indentation anyway. EditorConfig is great for targeting files in different locations, usually. |
We already have a configuration option to control the newline character, why not the indentation as well? |
The new line is used for the generated .js not as an editor configuration. here you are talking about editor configuration. Having said that, now there is a different way to set these options in different editors. maybe we should put formatting options in tsconfig.json and use it in all editors. @jrieken and @billti what do you think? |
@mhegazy I am absolutely NOT talking about the editor setting. My screenshot shows the original source on the top half and the compiled output on the bottom half. |
The TS compiler replaces leading-tab indentation with 4 spaces is my point. I'd like to control that! |
Ah.. Sorry my bad. In this case, if output formatting is important to you, we suggest you add a JS beautifier to your build. There are many formatting parameters like where to place curlies, spaces before and after keywords, etc.. And trying to do all adds a lot of complexity for small value. |
Allthough closed, will you please reconsider this issue. I was looking for an indent setting in the tsconfig.json file as well to met my companies styling guidelines for javascript (despite the suggestion for an extra JS beautifier run). If output formatting is no issue for you guys you may omit the line-ending setting as well |
Although it is closed, and I don't care about generated javascript, which I use uglify later. But I do care about the file size, which is 30~40% bigger with 4 spaces than single tab. Only supporting to specify tab or space and tabSize options should not be a complex issue, because you already writing 4 spaces there. Also adding another JS beautifier to just do that is too much to the build pipeline, and Typescript itself is already huge. |
I agree if you have a line ending setting, you might as well have a tab setting. No one is asking for full formatting options, just these two very common settings. That said, we have to do this to get tabs:
|
Is there an option available for this? I too prefer two spaces over three (for reasons). |
If I'm not mistaken, a PR to add configurable indentation was rejected: I would appreciate this option for the sake of keeping the diff between TS and emitted JS files minimal. (tsc could even detect source indentation.) |
Rejecting this is just because typescript authors want everyone to use four spaces. For those who just want to change the output to tab, you can patch typescript.js after you install.
That saved 25% of total file sizes in my project with tabs, less disk read/write is better for most cases, especially if you have live reload or watch to compile continuously. |
@S-YOU S you, too! .. But thank you, that helps. |
I would just love an
indent
option for the tsconfig.json file, not only for the obvious reason of preserving indentation, but also to prevent issues like the following, where I have TypeScript code with template strings compiling into an ES6 target:I would imagine as long as it supports 4 spaces, 2 spaces and tabs, that should fulfill most everyone's needs; however, flexibility would probably be best.
The text was updated successfully, but these errors were encountered: