Often, I find myself making a common mistake when writing TypeScript code:
class Foo {
constructor() { }
public get isFoo(): boolean { return true; } // getter
public isBar(): boolean { return false; } // normal function
}
let foo = new Foo();
if (foo.isFoo) { // This is correct as the getter returns true
console.log("it is foo");
}
// Here is where the mistake occurs:
if (foo.isBar) { // <-isBar is defined, forgot to include ()
console.log("it is bar"); // This will also execute
}
Is there any way to receive a warning from a tslinter or compiler for this type of mistake?