How to force TypeScript to not compile to JS when I have an error in ts code, with tsconfig file?

Viewed 2123

I didn't find in the default file: tsc --init

my config file

github code

{
  "compilerOptions" : {
      "target": "ES3",
      "module": "ES2015",
      "declaration": false,
      "sourceMap": true,
      "outDir": "./dist",
      "rootDir": "./src",
      
      "watch": true
  },
  
 
  "include": [
      "src/**/*"
  ]
} 
2 Answers

You need to add noEmitOnError: true in your tsconfig.json.

This flag controls if the typescript compiler should generate output files if any errors were reported. And by default it is false, meaning the compiler will still emit output files even when there are errors.

https://www.typescriptlang.org/tsconfig#noEmitOnError

I also had the same issue. I removed src in tsconfig after compilerOptions property. Then tsc command started showing type errors and imports.

Related