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
|
//// [typeParameterUsedAsTypeParameterConstraint4.ts]
// Type parameters are in scope in their own and other type parameter lists
// Some negative cases
class C<T, U extends T, V extends U> {
z: W; // error
foo<W extends V>(x: W): T {
var r: T;
return x;
}
}
interface I<T, U extends T, V extends U> {
x: T;
y: U;
z: W; // error
foo<W extends V>(x: W): T;
}
function foo<T, U extends T>(x: T, y: U): V { // error
function bar<V extends T, W extends U>(): X { // error
function baz<X extends W, Y extends V>(a: X, b: Y): T {
x = y;
return y;
}
}
}
function foo2<U extends T, T>(x: T, y: U): W { // error
function bar<V extends T, W extends U>(): Y { // error
function baz<X extends W, Y extends V>(a: X, b: Y): T {
x = y;
return y;
}
}
}
var f3 = <T, U extends T>(x: T, y: U) => {
function bar<V extends T, W extends U>(r: X, s: Y) { // error
var g = <X extends W, Y extends V>(a: X, b: Y): T => {
x = y;
return y;
}
}
}
var f4 = <U extends T, T>(x: V, y: X) => { // error
function bar<V extends T, W extends U>() {
var g = <X extends W, Y extends V>(a: X, b: Y): T => {
x = y;
return y;
}
}
}
//// [typeParameterUsedAsTypeParameterConstraint4.js]
// Type parameters are in scope in their own and other type parameter lists
// Some negative cases
var C = (function () {
function C() {
}
C.prototype.foo = function (x) {
var r;
return x;
};
return C;
}());
function foo(x, y) {
function bar() {
function baz(a, b) {
x = y;
return y;
}
}
}
function foo2(x, y) {
function bar() {
function baz(a, b) {
x = y;
return y;
}
}
}
var f3 = function (x, y) {
function bar(r, s) {
var g = function (a, b) {
x = y;
return y;
};
}
};
var f4 = function (x, y) {
function bar() {
var g = function (a, b) {
x = y;
return y;
};
}
};
|