2

this seems to be a less relevant problem, but I spent already 3 hours trying to figure this out and nothing.

Then basic setup: I have a project in node / javascript and I’m currently trying to use TypeScript in order to output a cleaner production code. So tsconfig.json looks like this:

{
  "compilerOptions": {
    
    "target": "es6",                                /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
    "module": "commonjs",                           /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
     "lib": [
       "DOM",
       "es6",
       "DOM.Iterable",
       "ScriptHost"
     ], //default                                  /* Specify library files to be included in the compilation. */
    "sourceMap": true,                           /* Generates corresponding '.map' file. */
    "removeComments": true,                      /* Do not emit comments to output. */
    "strict": true,                                 /* Enable all strict type-checking options. */
    "esModuleInterop": true,                        /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "skipLibCheck": true,                           /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true        /* Disallow inconsistently-cased references to the same file. */
  },
  "files": [
    "app_js/functions-syncsystem.ts"
  ]
}

And my prettier .prettierrc file looks like so:

{
    "singleQuote": true,
    "tabWidth": 2
}

On top of that, I’ve changed all configuration for tab spaces in the visual studio code to 2 spaces (user and workspace), besides unchecking “Detect Indentation”.

The problem: On my editor, everything works fine with the 2 spaces tab. But when I run tsc on the terminal, the output file has tab sizes of 4 and I can’t seem to change anywhere.

I’ve also tried many suggestions on this post: How to change indentation in Visual Studio Code?

Like this one too: https://stackoverflow.com/a/68082579/2510785

After each modification, I made sure I closed the editor and opened again and generated a another compiled file to be sure. Can anyone think of any other possibility that could fix this issue? The only thing I can think of is that it could be a specific problem in my OS / VS Code Instalation.

Thanks, Jorge Mauricio

1
  • The problem is tsc, not VS Code. Commented Mar 17, 2023 at 23:35

1 Answer 1

2

Changing the settings of VSCode won't have any effect on the tsc compiler.

At a quick glance, it doesn't seem to be possible to change the indentation style of tsc's output, see https://github.com/microsoft/TypeScript/issues/4042

This is likely because there seldom is a reason for a developer to edit the compiled output.

As a workaround, you could reformat the output files with something like prettier or using VSCode itself.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.