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

Jorge Mauricio
  • 411
  • 6
  • 18

1 Answers1

1

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.

a544jh
  • 738
  • 9
  • 15