1
- tests/cases/compiler/unionPropertyExistence.ts(24,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'.
1
+ tests/cases/compiler/unionPropertyExistence.ts(27,3): error TS2339: Property 'nope' does not exist on type '"foo" | "bar"'.
2
+ Property 'nope' does not exist on type '"foo"'.
3
+ tests/cases/compiler/unionPropertyExistence.ts(28,6): error TS2339: Property 'onlyInB' does not exist on type 'B | "foo"'.
4
+ Property 'onlyInB' does not exist on type '"foo"'.
5
+ tests/cases/compiler/unionPropertyExistence.ts(30,6): error TS2339: Property 'length' does not exist on type 'B | "foo"'.
6
+ Property 'length' does not exist on type 'B'.
7
+ tests/cases/compiler/unionPropertyExistence.ts(32,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'.
2
8
Property 'onlyInB' does not exist on type 'A'.
3
- tests/cases/compiler/unionPropertyExistence.ts(27 ,5): error TS2339: Property 'notInC' does not exist on type 'ABC'.
9
+ tests/cases/compiler/unionPropertyExistence.ts(35 ,5): error TS2339: Property 'notInC' does not exist on type 'ABC'.
4
10
Property 'notInC' does not exist on type 'C'.
5
- tests/cases/compiler/unionPropertyExistence.ts(28 ,4): error TS2339: Property 'notInB' does not exist on type 'AB'.
11
+ tests/cases/compiler/unionPropertyExistence.ts(36 ,4): error TS2339: Property 'notInB' does not exist on type 'AB'.
6
12
Property 'notInB' does not exist on type 'B'.
7
- tests/cases/compiler/unionPropertyExistence.ts(29 ,5): error TS2339: Property 'notInB' does not exist on type 'ABC'.
13
+ tests/cases/compiler/unionPropertyExistence.ts(37 ,5): error TS2339: Property 'notInB' does not exist on type 'ABC'.
8
14
Property 'notInB' does not exist on type 'B'.
9
- tests/cases/compiler/unionPropertyExistence.ts(32 ,5): error TS2339: Property 'inNone' does not exist on type 'ABC'.
15
+ tests/cases/compiler/unionPropertyExistence.ts(40 ,5): error TS2339: Property 'inNone' does not exist on type 'ABC'.
10
16
Property 'inNone' does not exist on type 'A'.
11
17
12
18
13
- ==== tests/cases/compiler/unionPropertyExistence.ts (5 errors) ====
19
+ ==== tests/cases/compiler/unionPropertyExistence.ts (8 errors) ====
14
20
interface A {
15
21
inAll: string;
16
22
notInB: string;
@@ -34,6 +40,23 @@ tests/cases/compiler/unionPropertyExistence.ts(32,5): error TS2339: Property 'in
34
40
var ab: AB;
35
41
var abc: ABC;
36
42
43
+ declare const x: "foo" | "bar";
44
+ declare const bFoo: B | "foo";
45
+
46
+ x.nope();
47
+ ~~~~
48
+ !!! error TS2339: Property 'nope' does not exist on type '"foo" | "bar"'.
49
+ !!! error TS2339: Property 'nope' does not exist on type '"foo"'.
50
+ bFoo.onlyInB;
51
+ ~~~~~~~
52
+ !!! error TS2339: Property 'onlyInB' does not exist on type 'B | "foo"'.
53
+ !!! error TS2339: Property 'onlyInB' does not exist on type '"foo"'.
54
+ x.length; // Ok
55
+ bFoo.length;
56
+ ~~~~~~
57
+ !!! error TS2339: Property 'length' does not exist on type 'B | "foo"'.
58
+ !!! error TS2339: Property 'length' does not exist on type 'B'.
59
+
37
60
ab.onlyInB;
38
61
~~~~~~~
39
62
!!! error TS2339: Property 'onlyInB' does not exist on type 'AB'.
@@ -57,4 +80,5 @@ tests/cases/compiler/unionPropertyExistence.ts(32,5): error TS2339: Property 'in
57
80
abc.inNone;
58
81
~~~~~~
59
82
!!! error TS2339: Property 'inNone' does not exist on type 'ABC'.
60
- !!! error TS2339: Property 'inNone' does not exist on type 'A'.
83
+ !!! error TS2339: Property 'inNone' does not exist on type 'A'.
84
+
0 commit comments