简体   繁体   中英

Disable javascript generation from typescript if an error is detected

I have started to use typescript in Visual Studio and it seems that the default behavior is to generate javascript even if the error is found. So really the only static compilation output I can see is the red underline if an error is detected. It is easy to overlook that really, so I would prefer if no js or some js that throws exception is generated in this case or some other form of explicit error. Is it possible to set up Visual Studio to do something like that?

Update: It seems there is an option to not emit on error, but that leaves the old js code, which is not a desired outcome, so I would like to hear about other simple options if they exist.

You can set the noEmmitOnError option to true in tsconfig.json .

eg.

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny": false,
    "sourceMap": false,
    "noEmitOnError": true
  },
  "exclude": [
    "node_modules"
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM