File: intersectionThisTypes.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (124 lines) | stat: -rw-r--r-- 2,668 bytes parent folder | download | duplicates (3)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
=== tests/cases/conformance/types/intersection/intersectionThisTypes.ts ===
interface Thing1 {
    a: number;
>a : number

    self(): this;
>self : () => this
}

interface Thing2 {
    b: number;
>b : number

    me(): this;
>me : () => this
}

type Thing3 = Thing1 & Thing2;
>Thing3 : Thing1 & Thing2

type Thing4 = Thing3 & string[];
>Thing4 : Thing1 & Thing2 & string[]

function f1(t: Thing3) {
>f1 : (t: Thing3) => void
>t : Thing3

    t = t.self();
>t = t.self() : Thing3
>t : Thing3
>t.self() : Thing3
>t.self : () => Thing3
>t : Thing3
>self : () => Thing3

    t = t.me().self().me();
>t = t.me().self().me() : Thing3
>t : Thing3
>t.me().self().me() : Thing3
>t.me().self().me : () => Thing3
>t.me().self() : Thing3
>t.me().self : () => Thing3
>t.me() : Thing3
>t.me : () => Thing3
>t : Thing3
>me : () => Thing3
>self : () => Thing3
>me : () => Thing3
}

interface Thing5 extends Thing4 {
    c: string;
>c : string
}

function f2(t: Thing5) {
>f2 : (t: Thing5) => void
>t : Thing5

    t = t.self();
>t = t.self() : Thing5
>t : Thing5
>t.self() : Thing5
>t.self : () => Thing5
>t : Thing5
>self : () => Thing5

    t = t.me().self().me();
>t = t.me().self().me() : Thing5
>t : Thing5
>t.me().self().me() : Thing5
>t.me().self().me : () => Thing5
>t.me().self() : Thing5
>t.me().self : () => Thing5
>t.me() : Thing5
>t.me : () => Thing5
>t : Thing5
>me : () => Thing5
>self : () => Thing5
>me : () => Thing5
}

interface Component {
    extend<T>(props: T): this & T;
>extend : <T>(props: T) => this & T
>props : T
}

interface Label extends Component {
    title: string;
>title : string
}

function test(label: Label) {
>test : (label: Label) => void
>label : Label

    const extended = label.extend({ id: 67 }).extend({ tag: "hello" });
>extended : Label & { id: number; } & { tag: string; }
>label.extend({ id: 67 }).extend({ tag: "hello" }) : Label & { id: number; } & { tag: string; }
>label.extend({ id: 67 }).extend : <T>(props: T) => Label & { id: number; } & T
>label.extend({ id: 67 }) : Label & { id: number; }
>label.extend : <T>(props: T) => Label & T
>label : Label
>extend : <T>(props: T) => Label & T
>{ id: 67 } : { id: number; }
>id : number
>67 : 67
>extend : <T>(props: T) => Label & { id: number; } & T
>{ tag: "hello" } : { tag: string; }
>tag : string
>"hello" : "hello"

    extended.id;  // Ok
>extended.id : number
>extended : Label & { id: number; } & { tag: string; }
>id : number

    extended.tag;  // Ok
>extended.tag : string
>extended : Label & { id: number; } & { tag: string; }
>tag : string
}