TypeScript Version:
1.8.0
Code
// A self-contained demonstration of the problem follows...
class A {
constructor(a: number, b: boolean) {
}
foo() {
}
bar: boolean;
}
function doIt(a: A) {
if (a instanceof A) {
}
}
doIt(new A(1, true));
doIt({ foo() { }, bar: false }); // expect type check error
Expected behavior:
The second to doIt should raise a type check error.
Actual behavior:
It does not. I assume it was a conscious decision and I wonder why? This break assumptions the instanceof operator makes and has led to subtle bugs on our side.
TypeScript Version:
1.8.0
Code
Expected behavior:
The second to
doItshould raise a type check error.Actual behavior:
It does not. I assume it was a conscious decision and I wonder why? This break assumptions the
instanceofoperator makes and has led to subtle bugs on our side.