Can I get Typescript to prevent compilation on errors?

I just started using TypeScript and am using the barbatus package and I noticed that my create react app typescript app will fail to compile if there’s an error like an any used in the program.

However, with the Meteor plugin it just prints out the error and keeps moving along. I would really like to prevent a build from being built before moving on. Is this possible? I’m currently running TS Lint as a separate step to prevent this from getting onto master but would love to catch it sooner.

AFAIK no, because using any explicitly, implies developer intent, therefore is valid code, so the compile step will never throw on that.

The compiler can check for implicit use of any as in const foo = x => bar(x) where x is implicityly any but as soon as you declare it with :any then the compiler will trust that you know what you are doing.

Now tslint is what it is, a linter, it checks your code for stylistic issues that are otherwise valid code.

I don’t know if you can pipe tslint through meteor’s build steps, though. I guess it would be doable by means of creating a new build plugin that accepts a linter as a step.

Oh ok thanks for the info. Yeah somehow create react app with typescript will halt compiling and then show you the error in browser and the terminal

1 Like