sumi sumi - 8 months ago 38
Javascript Question

JavaScript file should not get generated if Typescript file has any error

Consider below Typescript code

class formal
private startString: String = "";
this.startString = startString;

public sayHello = function() :Number {


var myIntro = new formal("hello world");

Currently It has following error
"A function whose declared type is neither 'void' nor 'any' must return a value.
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.

But after running tsc command it is generating corresponding js file.
What I need is that it should not generate corresponding JS file until all the errors are resolved of typescript file.

Is there any way to achieve this?


add --noEmitOnError to your compiler.

It would properly look something like this: tsc myFile.ts -w --noEmitOnError