TypeScript/tests/cases/conformance/controlFlow/controlFlowInstanceofExtendsFunction.ts
Wesley Wigham f07404938f
Replace subtype check in derivedness check with flags and structure checks (#27403)
* Replace subtype check in derivedness check with flags and structure checks

* Remove now extraneous clause
2018-10-04 12:55:39 -07:00

32 lines
456 B
TypeScript

declare global {
interface Function {
now(): string;
}
}
Function.prototype.now = function () {
return "now"
}
class X {
static now() {
return {}
}
why() {
}
}
class Y {
}
console.log(X.now()) // works as expected
console.log(Y.now()) // works as expected
export const x: X | number = Math.random() > 0.5 ? new X() : 1
if (x instanceof X) {
x.why() // should compile
}