Skip to content

Commit 59c09d9

Browse files
committed
Update instanceof conformance tests
1 parent 3835302 commit 59c09d9

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (obj1 instanceof A) { // narrowed to A.
1313
}
1414

1515
var obj2: any;
16-
if (obj2 instanceof A) { // can't narrow type from 'any'
16+
if (obj2 instanceof A) {
1717
obj2.foo;
1818
obj2.bar;
1919
}
@@ -35,7 +35,7 @@ if (obj3 instanceof B) { // narrowed to B<number>.
3535
}
3636

3737
var obj4: any;
38-
if (obj4 instanceof B) { // can't narrow type from 'any'
38+
if (obj4 instanceof B) {
3939
obj4.foo = "str";
4040
obj4.foo = 1;
4141
obj4.bar = "str";
@@ -67,7 +67,7 @@ if (obj5 instanceof C) { // narrowed to C1|C2.
6767
}
6868

6969
var obj6: any;
70-
if (obj6 instanceof C) { // can't narrow type from 'any'
70+
if (obj6 instanceof C) {
7171
obj6.foo;
7272
obj6.bar1;
7373
obj6.bar2;
@@ -86,7 +86,7 @@ if (obj7 instanceof D) { // narrowed to D.
8686
}
8787

8888
var obj8: any;
89-
if (obj8 instanceof D) { // can't narrow type from 'any'
89+
if (obj8 instanceof D) {
9090
obj8.foo;
9191
obj8.bar;
9292
}
@@ -113,7 +113,7 @@ if (obj9 instanceof E) { // narrowed to E1 | E2
113113
}
114114

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

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

163163
var obj14: any;
164-
if (obj14 instanceof G) { // can't narrow type from 'any'
164+
if (obj14 instanceof G) {
165165
obj14.foo1;
166166
obj14.foo2;
167167
}
@@ -183,7 +183,19 @@ if (obj15 instanceof H) { // narrowed to H.
183183
}
184184

185185
var obj16: any;
186-
if (obj16 instanceof H) { // can't narrow type from 'any'
186+
if (obj16 instanceof H) {
187187
obj16.foo1;
188188
obj16.foo2;
189189
}
190+
191+
var obj17: any;
192+
if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object'
193+
obj17.foo1;
194+
obj17.foo2;
195+
}
196+
197+
var obj18: any;
198+
if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function'
199+
obj18.foo1;
200+
obj18.foo2;
201+
}

0 commit comments

Comments
 (0)