Ali Dhuniya
Ali Dhuniya

Reputation: 67

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

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/**/*"
  ]
} 

Upvotes: 4

Views: 10957

Answers (3)

Glad to see you
Glad to see you

Reputation: 1

Add them to config.json, then append the .ts extension after every import.

{
    "noEmit": true,
    "allowImportingTsExtensions": true
}

Upvotes: 0

Pranu Pranav
Pranu Pranav

Reputation: 501

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

Upvotes: 0

Abito Prakash
Abito Prakash

Reputation: 4770

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

Upvotes: 9

Related Questions