How can I disable tsc pretty printing via the config file

65 views Asked by At

I have a simple, deliberately broken typescript program.

12:17:23:~/hello  $ cat hello.ts
console.log("Hello World"
12:17:29:~/hello  $ cat package.json 
{
  "dependencies": {
    "typescript": "^5.2.2"
  }
}

With a fairly basic typescript config:

12:17:32:~/hello  $ cat tsconfig.json 
{
  "compilerOptions": {
    "preserveConstEnums": true,
    "strictNullChecks": false,
    "sourceMap": true,
    "allowJs": true,
    "target": "es6",
    "outDir": ".build",
    "moduleResolution": "node",
    "lib": ["es2022"],
    "rootDir": "./",
    "experimentalDecorators": true,
    "module": "commonjs",
    "pretty": false
  }
}
12:17:39:~/hello  $

Note that I'm supposedly turning off pretty printing in the last line, as per https://www.typescriptlang.org/tsconfig#pretty

Despite this if I run it, I get "pretty" output:

12:17:39:~/hello  $ tsc hello.ts
hello.ts:2:1 - error TS1005: ')' expected.

2 
  


Found 1 error in hello.ts:2

12:17:53:~/hello  $ 

If I turn it off as a command line arg it works correctly:

12:17:53:~/hello  $ tsc --pretty false hello.ts
hello.ts(2,1): error TS1005: ')' expected.
12:18:00:~/hello  $ 

So how do I update the config file to achieve the same outcome?

1

There are 1 answers

1
Dimava On

Same as every other compiler options it's in tsconfig

{
  "compilerOptions": {
    "pretty": false
  },
}