2014-07-13 01:04:16 +02:00
|
|
|
//// [typeParameterAsTypeParameterConstraintTransitively.ts]
|
|
|
|
// using a type parameter as a constraint for a type parameter is valid
|
|
|
|
// no errors expected
|
|
|
|
|
|
|
|
interface A { foo: number }
|
|
|
|
interface B extends A { bar: string; }
|
|
|
|
interface C extends B { baz: boolean; }
|
|
|
|
var a: A;
|
|
|
|
var b: B;
|
|
|
|
var c: C;
|
|
|
|
|
|
|
|
function foo<T, U, V>(x: T, y: U, z: V): V { return z; }
|
|
|
|
//function foo<T, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
|
|
|
|
|
|
|
|
foo(1, 2, 3);
|
|
|
|
foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: '', z: true });
|
|
|
|
foo(a, b, c);
|
|
|
|
foo(a, b, { foo: 1, bar: '', hm: true });
|
|
|
|
foo((x: number, y) => { }, (x) => { }, () => { });
|
|
|
|
|
|
|
|
function foo2<T extends A, U, V>(x: T, y: U, z: V): V { return z; }
|
|
|
|
//function foo2<T extends A, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
|
|
|
|
foo(a, a, a);
|
|
|
|
foo(a, b, c);
|
|
|
|
foo(b, b, { foo: 1, bar: '', hm: '' });
|
|
|
|
|
|
|
|
//// [typeParameterAsTypeParameterConstraintTransitively.js]
|
2014-08-19 19:43:13 +02:00
|
|
|
// using a type parameter as a constraint for a type parameter is valid
|
|
|
|
// no errors expected
|
2014-07-13 01:04:16 +02:00
|
|
|
var a;
|
|
|
|
var b;
|
|
|
|
var c;
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo(x, y, z) { return z; }
|
2014-08-16 00:49:09 +02:00
|
|
|
//function foo<T, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
|
2014-07-13 01:04:16 +02:00
|
|
|
foo(1, 2, 3);
|
|
|
|
foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: '', z: true });
|
|
|
|
foo(a, b, c);
|
|
|
|
foo(a, b, { foo: 1, bar: '', hm: true });
|
2015-02-07 03:45:09 +01:00
|
|
|
foo(function (x, y) { }, function (x) { }, function () { });
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo2(x, y, z) { return z; }
|
2014-08-16 00:49:09 +02:00
|
|
|
//function foo2<T extends A, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
|
2014-07-13 01:04:16 +02:00
|
|
|
foo(a, a, a);
|
|
|
|
foo(a, b, c);
|
|
|
|
foo(b, b, { foo: 1, bar: '', hm: '' });
|