File: recursiveTypesUsedAsFunctionParameters.types

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 (106 lines) | stat: -rw-r--r-- 2,591 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
=== tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypesUsedAsFunctionParameters.ts ===
class List<T> {
>List : List<T>

    data: T;
>data : T

    next: List<List<T>>;
>next : List<List<T>>
}

class MyList<T> {
>MyList : MyList<T>

    data: T;
>data : T

    next: MyList<MyList<T>>;
>next : MyList<MyList<T>>
}

function foo<T>(x: List<T>);
>foo : { <T>(x: List<T>): any; <U>(x: List<U>): any; }
>x : List<T>

function foo<U>(x: List<U>); // error, duplicate
>foo : { <T>(x: List<T>): any; <U>(x: List<U>): any; }
>x : List<U>

function foo<T>(x: List<T>) {
>foo : { <T>(x: List<T>): any; <U>(x: List<U>): any; }
>x : List<T>
}

function foo2<T>(x: List<T>);
>foo2 : { <T>(x: List<T>): any; <U>(x: MyList<U>): any; }
>x : List<T>

function foo2<U>(x: MyList<U>); // ok, nominally compared with first overload
>foo2 : { <T>(x: List<T>): any; <U>(x: MyList<U>): any; }
>x : MyList<U>

function foo2<T>(x: any) {
>foo2 : { <T>(x: List<T>): any; <U>(x: MyList<U>): any; }
>x : any
}

function other<T extends List<U>, U>() {
>other : <T extends List<U>, U>() => void

    // error but wrong error
    // BUG 838247
    function foo3<V>(x: T);
>foo3 : <V>(x: T) => any
>x : T

    function foo3<V>(x: MyList<V>) { }
>foo3 : <V>(x: T) => any
>x : MyList<V>

    // should be error
    // BUG 838247
    function foo4<V>(x: T);
>foo4 : <V>(x: T) => any
>x : T

    function foo4<V>(x: List<V>) { }
>foo4 : <V>(x: T) => any
>x : List<V>

    // ok
    function foo5<V>(x: T): string;
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>x : T

    function foo5<V>(x: List<V>): number;
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>x : List<V>

    function foo5<V>(x: MyList<V>): boolean;
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>x : MyList<V>

    function foo5<V>(x: any): any { return null; }
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>x : any
>null : null

    var list: List<string>;
>list : List<string>

    var myList: MyList<string>;
>myList : MyList<string>

    var r = foo5(list);
>r : number
>foo5(list) : number
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>list : List<string>

    var r2 = foo5(myList);
>r2 : number
>foo5(myList) : number
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>myList : MyList<string>
}