Skip to content

Commit

Permalink
Update instanceof conformance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yortus committed Aug 13, 2016
1 parent 0ad47db commit 4837be0
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (obj1 instanceof A) { // narrowed to A.
}

var obj2: any;
if (obj2 instanceof A) { // can't narrow type from 'any'
if (obj2 instanceof A) {
obj2.foo;
obj2.bar;
}
Expand All @@ -35,7 +35,7 @@ if (obj3 instanceof B) { // narrowed to B<number>.
}

var obj4: any;
if (obj4 instanceof B) { // can't narrow type from 'any'
if (obj4 instanceof B) {
obj4.foo = "str";
obj4.foo = 1;
obj4.bar = "str";
Expand Down Expand Up @@ -67,7 +67,7 @@ if (obj5 instanceof C) { // narrowed to C1|C2.
}

var obj6: any;
if (obj6 instanceof C) { // can't narrow type from 'any'
if (obj6 instanceof C) {
obj6.foo;
obj6.bar1;
obj6.bar2;
Expand All @@ -86,7 +86,7 @@ if (obj7 instanceof D) { // narrowed to D.
}

var obj8: any;
if (obj8 instanceof D) { // can't narrow type from 'any'
if (obj8 instanceof D) {
obj8.foo;
obj8.bar;
}
Expand All @@ -113,7 +113,7 @@ if (obj9 instanceof E) { // narrowed to E1 | E2
}

var obj10: any;
if (obj10 instanceof E) { // can't narrow type from 'any'
if (obj10 instanceof E) {
obj10.foo;
obj10.bar1;
obj10.bar2;
Expand All @@ -136,7 +136,7 @@ if (obj11 instanceof F) { // can't type narrowing, construct signature returns a
}

var obj12: any;
if (obj12 instanceof F) { // can't narrow type from 'any'
if (obj12 instanceof F) {
obj12.foo;
obj12.bar;
}
Expand All @@ -161,7 +161,7 @@ if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype prop
}

var obj14: any;
if (obj14 instanceof G) { // can't narrow type from 'any'
if (obj14 instanceof G) {
obj14.foo1;
obj14.foo2;
}
Expand All @@ -183,7 +183,19 @@ if (obj15 instanceof H) { // narrowed to H.
}

var obj16: any;
if (obj16 instanceof H) { // can't narrow type from 'any'
if (obj16 instanceof H) {
obj16.foo1;
obj16.foo2;
}

var obj17: any;
if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object'
obj17.foo1;
obj17.foo2;
}

var obj18: any;
if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function'
obj18.foo1;
obj18.foo2;
}

0 comments on commit 4837be0

Please sign in to comment.