File: typeParameterFixingWithContextSensitiveArguments.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (59 lines) | stat: -rw-r--r-- 1,108 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
=== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments.ts ===
function f<T, U>(y: T, f: (x: T) => U, x: T): [T, U] { return [y, f(x)]; }
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>y : T
>f : (x: T) => U
>x : T
>x : T
>[y, f(x)] : [T, U]
>y : T
>f(x) : U
>f : (x: T) => U
>x : T

interface A { a: A; }
>a : A

interface B extends A { b; }
>b : any

var a: A, b: B;
>a : A
>b : B

var d = f(b, x => x.a, a); // type [A, A]
>d : [A, A]
>f(b, x => x.a, a) : [A, A]
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>b : B
>x => x.a : (x: A) => A
>x : A
>x.a : A
>x : A
>a : A
>a : A

var d2 = f(b, x => x.a, null); // type [B, A]
>d2 : [B, A]
>f(b, x => x.a, null) : [B, A]
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>b : B
>x => x.a : (x: B) => A
>x : B
>x.a : A
>x : B
>a : A
>null : null

var d3 = f(b, x => x.b, null); // type [B, any]
>d3 : [B, any]
>f(b, x => x.b, null) : [B, any]
>f : <T, U>(y: T, f: (x: T) => U, x: T) => [T, U]
>b : B
>x => x.b : (x: B) => any
>x : B
>x.b : any
>x : B
>b : any
>null : null