Skip to content

Commit e535c0c

Browse files
Accepted baselines.
1 parent 3230804 commit e535c0c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts(13,17): error TS2345: Argument of type 'A<T> | B<T>' is not assignable to parameter of type 'A<T>'.
2+
Type 'B<T>' is not assignable to type 'A<T>'.
3+
Property 'a' is missing in type 'B<T>'.
4+
5+
6+
==== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts (1 errors) ====
7+
class A<T> {
8+
constructor(private a: string) { }
9+
}
10+
11+
class B<T> {
12+
}
13+
14+
function acceptA<T>(a: A<T>) { }
15+
function acceptB<T>(b: B<T>) { }
16+
17+
function test<T>(x: A<T> | B<T>) {
18+
if (x instanceof B) {
19+
acceptA(x);
20+
~
21+
!!! error TS2345: Argument of type 'A<T> | B<T>' is not assignable to parameter of type 'A<T>'.
22+
!!! error TS2345: Type 'B<T>' is not assignable to type 'A<T>'.
23+
!!! error TS2345: Property 'a' is missing in type 'B<T>'.
24+
}
25+
26+
if (x instanceof A) {
27+
acceptA(x);
28+
}
29+
30+
if (x instanceof B) {
31+
acceptB(x);
32+
}
33+
34+
if (x instanceof B) {
35+
acceptB(x);
36+
}
37+
}

0 commit comments

Comments
 (0)