File: typeParameterAsTypeParameterConstraintTransitively2.types

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (135 lines) | stat: -rw-r--r-- 2,810 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
130
131
132
133
134
135
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraintTransitively2.ts ===
// using a type parameter as a constraint for a type parameter is invalid
// these should be errors at the type parameter constraint declarations, and have no downstream errors

interface A { foo: number }
>A : A
>foo : number

interface B extends A { bar: string; }
>B : B
>A : A
>bar : string

interface C extends B { baz: boolean; }
>C : C
>B : B
>baz : boolean

var a: A;
>a : A
>A : A

var b: B;
>b : B
>B : B

var c: C;
>c : C
>C : C

function foo<T, U, V>(x: T, y: U, z: V): V { return z; }
>foo : <T, U, V>(x: T, y: U, z: V) => V
>T : T
>U : U
>V : V
>x : T
>T : T
>y : U
>U : U
>z : V
>V : V
>V : V
>z : V

//function foo<T, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }

foo(1, 2, '');
>foo(1, 2, '') : ""
>foo : <T, U, V>(x: T, y: U, z: V) => V
>1 : 1
>2 : 2
>'' : ""

foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true });
>foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true }) : { x: number; y: number; z: boolean; }
>foo : <T, U, V>(x: T, y: U, z: V) => V
>{ x: 1 } : { x: number; }
>x : number
>1 : 1
>{ x: 1, y: '' } : { x: number; y: string; }
>x : number
>1 : 1
>y : string
>'' : ""
>{ x: 2, y: 2, z: true } : { x: number; y: number; z: true; }
>x : number
>2 : 2
>y : number
>2 : 2
>z : boolean
>true : true

foo(a, b, a);
>foo(a, b, a) : A
>foo : <T, U, V>(x: T, y: U, z: V) => V
>a : A
>b : B
>a : A

foo(a, { foo: 1, bar: '', hm: true }, b);
>foo(a, { foo: 1, bar: '', hm: true }, b) : B
>foo : <T, U, V>(x: T, y: U, z: V) => V
>a : A
>{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: true; }
>foo : number
>1 : 1
>bar : string
>'' : ""
>hm : boolean
>true : true
>b : B

foo((x: number, y: string) => { }, (x, y: boolean) => { }, () => { });
>foo((x: number, y: string) => { }, (x, y: boolean) => { }, () => { }) : () => void
>foo : <T, U, V>(x: T, y: U, z: V) => V
>(x: number, y: string) => { } : (x: number, y: string) => void
>x : number
>y : string
>(x, y: boolean) => { } : (x: any, y: boolean) => void
>x : any
>y : boolean
>() => { } : () => void

function foo2<T extends A, U extends A, V extends A>(x: T, y: U, z: V): V { return z; }
>foo2 : <T extends A, U extends A, V extends A>(x: T, y: U, z: V) => V
>T : T
>A : A
>U : U
>A : A
>V : V
>A : A
>x : T
>T : T
>y : U
>U : U
>z : V
>V : V
>V : V
>z : V

//function foo2<T extends A, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
foo(b, a, c);
>foo(b, a, c) : C
>foo : <T, U, V>(x: T, y: U, z: V) => V
>b : B
>a : A
>c : C

foo(c, c, a);
>foo(c, c, a) : A
>foo : <T, U, V>(x: T, y: U, z: V) => V
>c : C
>c : C
>a : A