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
|
//// [recursiveTypesUsedAsFunctionParameters.ts]
class List<T> {
data: T;
next: List<List<T>>;
}
class MyList<T> {
data: T;
next: MyList<MyList<T>>;
}
function foo<T>(x: List<T>);
function foo<U>(x: List<U>); // error, duplicate
function foo<T>(x: List<T>) {
}
function foo2<T>(x: List<T>);
function foo2<U>(x: MyList<U>); // ok, nominally compared with first overload
function foo2<T>(x: any) {
}
function other<T extends List<U>, U>() {
// error but wrong error
// BUG 838247
function foo3<V>(x: T);
function foo3<V>(x: MyList<V>) { }
// should be error
// BUG 838247
function foo4<V>(x: T);
function foo4<V>(x: List<V>) { }
// ok
function foo5<V>(x: T): string;
function foo5<V>(x: List<V>): number;
function foo5<V>(x: MyList<V>): boolean;
function foo5<V>(x: any): any { return null; }
var list: List<string>;
var myList: MyList<string>;
var r = foo5(list);
var r2 = foo5(myList);
}
//// [recursiveTypesUsedAsFunctionParameters.js]
var List = /** @class */ (function () {
function List() {
}
return List;
}());
var MyList = /** @class */ (function () {
function MyList() {
}
return MyList;
}());
function foo(x) {
}
function foo2(x) {
}
function other() {
function foo3(x) { }
function foo4(x) { }
function foo5(x) { return null; }
var list;
var myList;
var r = foo5(list);
var r2 = foo5(myList);
}
|