Add tests

This commit is contained in:
Anders Hejlsberg 2017-11-19 09:50:45 -08:00
parent 40579472a2
commit 3d153e2ac3

View file

@ -0,0 +1,36 @@
// @strict: true
// Repro from #20138
class C { }
function f1<T extends C>(v: T | string): void {
if (v instanceof C) {
const x: T = v;
}
else {
const s: string = v;
}
}
class D { }
function f2<T extends C, U extends D>(v: T | U) {
if (v instanceof C) {
const x: T = v;
}
else {
const y: U = v;
}
}
class E { x: string }
function f3<T extends E>(v: T | { x: string }) {
if (v instanceof E) {
const x: T = v;
}
else {
const y: { x: string } = v;
}
}