1

Consider below Typescript code

class formal
{
    private startString: String = "";
    constructor(startString:String)
    {
        this.startString = startString;
    }

    public sayHello = function() :Number {
       alert(this.startString);
    }     

}

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

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?

1 Answer 1

1

add --noEmitOnError to your compiler.

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

Sign up to request clarification or add additional context in comments.

1 Comment

If you are interested in other compiler settings, the command tsc -h will show all options

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.