File: genericCallWithObjectTypeArgs2.types

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (129 lines) | stat: -rw-r--r-- 2,858 bytes parent folder | download | duplicates (2)
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
125
126
127
128
129
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs2.ts ===
class Base {
>Base : Base

    x: string;
>x : string
}
class Derived extends Base {
>Derived : Derived
>Base : Base

    y: string;
>y : string
}
class Derived2 extends Base {
>Derived2 : Derived2
>Base : Base

    z: string;
>z : string
}

// returns {}[]
function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (T | U)[]
>T : T
>Base : Base
>U : U
>Base : Base
>a : { x: T; y: U; }
>x : T
>T : T
>y : U
>U : U

    return [a.x, a.y];
>[a.x, a.y] : (T | U)[]
>a.x : T
>a : { x: T; y: U; }
>x : T
>a.y : U
>a : { x: T; y: U; }
>y : U
}

var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>r : (Derived | Derived2)[]
>f({ x: new Derived(), y: new Derived2() }) : (Derived | Derived2)[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (T | U)[]
>{ x: new Derived(), y: new Derived2() } : { x: Derived; y: Derived2; }
>x : Derived
>new Derived() : Derived
>Derived : typeof Derived
>y : Derived2
>new Derived2() : Derived2
>Derived2 : typeof Derived2

var r2 = f({ x: new Base(), y: new Derived2() }); // {}[]
>r2 : (Base | Derived2)[]
>f({ x: new Base(), y: new Derived2() }) : (Base | Derived2)[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (T | U)[]
>{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; }
>x : Base
>new Base() : Base
>Base : typeof Base
>y : Derived2
>new Derived2() : Derived2
>Derived2 : typeof Derived2


function f2<T extends Base, U extends Base>(a: { x: T; y: U }) {
>f2 : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (x: T) => U
>T : T
>Base : Base
>U : U
>Base : Base
>a : { x: T; y: U; }
>x : T
>T : T
>y : U
>U : U

    return (x: T) => a.y;
>(x: T) => a.y : (x: T) => U
>x : T
>T : T
>a.y : U
>a : { x: T; y: U; }
>y : U
}

var r3 = f2({ x: new Derived(), y: new Derived2() }); // Derived => Derived2
>r3 : (x: Derived) => Derived2
>f2({ x: new Derived(), y: new Derived2() }) : (x: Derived) => Derived2
>f2 : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (x: T) => U
>{ x: new Derived(), y: new Derived2() } : { x: Derived; y: Derived2; }
>x : Derived
>new Derived() : Derived
>Derived : typeof Derived
>y : Derived2
>new Derived2() : Derived2
>Derived2 : typeof Derived2

interface I<T, U> {
>I : I<T, U>
>T : T
>U : U

    x: T;
>x : T
>T : T

    y: U;
>y : U
>U : U
}

var i: I<Base, Derived>;
>i : I<Base, Derived>
>I : I<T, U>
>Base : Base
>Derived : Derived

var r4 = f2(i); // Base => Derived
>r4 : (x: Base) => Derived
>f2(i) : (x: Base) => Derived
>f2 : <T extends Base, U extends Base>(a: { x: T; y: U; }) => (x: T) => U
>i : I<Base, Derived>