File: typeParameterAsTypeParameterConstraintTransitively.js

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 (44 lines) | stat: -rw-r--r-- 1,534 bytes parent folder | download | duplicates (7)
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
//// [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]
// using a type parameter as a constraint for a type parameter is valid
// no errors expected
var a;
var b;
var c;
function foo(x, y, z) { 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(function (x, y) { }, function (x) { }, function () { });
function foo2(x, y, z) { 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: '' });