File: unionPropertyExistence.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (84 lines) | stat: -rw-r--r-- 3,392 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
tests/cases/compiler/unionPropertyExistence.ts(27,3): error TS2339: Property 'nope' does not exist on type '"foo" | "bar"'.
  Property 'nope' does not exist on type '"foo"'.
tests/cases/compiler/unionPropertyExistence.ts(28,6): error TS2339: Property 'onlyInB' does not exist on type 'B | "foo"'.
  Property 'onlyInB' does not exist on type '"foo"'.
tests/cases/compiler/unionPropertyExistence.ts(30,6): error TS2339: Property 'length' does not exist on type 'B | "foo"'.
  Property 'length' does not exist on type 'B'.
tests/cases/compiler/unionPropertyExistence.ts(32,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'.
  Property 'onlyInB' does not exist on type 'A'.
tests/cases/compiler/unionPropertyExistence.ts(35,5): error TS2339: Property 'notInC' does not exist on type 'ABC'.
  Property 'notInC' does not exist on type 'C'.
tests/cases/compiler/unionPropertyExistence.ts(36,4): error TS2551: Property 'notInB' does not exist on type 'AB'. Did you mean 'notInC'?
  Property 'notInB' does not exist on type 'B'.
tests/cases/compiler/unionPropertyExistence.ts(37,5): error TS2339: Property 'notInB' does not exist on type 'ABC'.
  Property 'notInB' does not exist on type 'B'.
tests/cases/compiler/unionPropertyExistence.ts(40,5): error TS2339: Property 'inNone' does not exist on type 'ABC'.
  Property 'inNone' does not exist on type 'A'.


==== tests/cases/compiler/unionPropertyExistence.ts (8 errors) ====
    interface A {
        inAll: string;
        notInB: string;
        notInC: string;
    }
    
    interface B {
        inAll: boolean;
        onlyInB: number;
        notInC: string;
    }
    
    interface C {
        inAll: number;
        notInB: string;
    }
    
    type AB = A | B;
    type ABC = C | AB;
    
    var ab: AB;
    var abc: ABC;
    
    declare const x: "foo" | "bar";
    declare const bFoo: B | "foo";
    
    x.nope();
      ~~~~
!!! error TS2339: Property 'nope' does not exist on type '"foo" | "bar"'.
!!! error TS2339:   Property 'nope' does not exist on type '"foo"'.
    bFoo.onlyInB;
         ~~~~~~~
!!! error TS2339: Property 'onlyInB' does not exist on type 'B | "foo"'.
!!! error TS2339:   Property 'onlyInB' does not exist on type '"foo"'.
    x.length; // Ok
    bFoo.length;
         ~~~~~~
!!! error TS2339: Property 'length' does not exist on type 'B | "foo"'.
!!! error TS2339:   Property 'length' does not exist on type 'B'.
    
    ab.onlyInB;
       ~~~~~~~
!!! error TS2339: Property 'onlyInB' does not exist on type 'AB'.
!!! error TS2339:   Property 'onlyInB' does not exist on type 'A'.
    
    ab.notInC; // Ok
    abc.notInC;
        ~~~~~~
!!! error TS2339: Property 'notInC' does not exist on type 'ABC'.
!!! error TS2339:   Property 'notInC' does not exist on type 'C'.
    ab.notInB;
       ~~~~~~
!!! error TS2551: Property 'notInB' does not exist on type 'AB'. Did you mean 'notInC'?
!!! error TS2551:   Property 'notInB' does not exist on type 'B'.
    abc.notInB;
        ~~~~~~
!!! error TS2339: Property 'notInB' does not exist on type 'ABC'.
!!! error TS2339:   Property 'notInB' does not exist on type 'B'.
    
    abc.inAll; // Ok
    abc.inNone;
        ~~~~~~
!!! error TS2339: Property 'inNone' does not exist on type 'ABC'.
!!! error TS2339:   Property 'inNone' does not exist on type 'A'.