This lesson is for PRO members.

Unlock this lesson NOW!
Already subscribed? sign in

Stopping a TypeScript Build When Errors Are Found

0:58 TypeScript lesson by

TypeScript will always compile even if there are ridiculous errors in your project. This lesson shows how to configure your .tsconfig with "noEmitOnError" so that no files are output if tsc reports an error.


egghead.io comment guidelines

Avatar
egghead.io

TypeScript will always compile even if there are ridiculous errors in your project. This lesson shows how to configure your .tsconfig with "noEmitOnError" so that no files are output if tsc reports an error.

When your code has errors in it, I'll just type some obvious errors, your IDE, your tooling, will probably tell you what's going on and that there's errors, there. If I come in here and I run TSC, you'll see it prints out all of these errors, lets you know that all that stuff happened, but it still actually compiles all of this.

If you don't want it to compile when an error happens, you have to define "No emit on error" to "True." This way, when you have an error in your main file, and I'm going to delete my dist directory to show that that this is not compiling now, when I run TSC, you'll see it shows all those errors. It also did not create that dist file with the compiled files.

If you set this to "Faults," I'll hit "Save," run TSC, you'll see this time, it does create the dist with the weird, crazy errors that I made.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?