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 107 108 109 110
|
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraintTransitively2.ts ===
// using a type parameter as a constraint for a type parameter is invalid
// these should be errors at the type parameter constraint declarations, and have no downstream errors
interface A { foo: number }
>foo : number
interface B extends A { bar: string; }
>bar : string
interface C extends B { baz: boolean; }
>baz : boolean
var a: A;
>a : A
var b: B;
>b : B
var c: C;
>c : C
function foo<T, U, V>(x: T, y: U, z: V): V { return z; }
>foo : <T, U, V>(x: T, y: U, z: V) => V
>x : T
>y : U
>z : V
>z : V
//function foo<T, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
foo(1, 2, '');
>foo(1, 2, '') : ""
>foo : <T, U, V>(x: T, y: U, z: V) => V
>1 : 1
>2 : 2
>'' : ""
foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true });
>foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true }) : { x: number; y: number; z: boolean; }
>foo : <T, U, V>(x: T, y: U, z: V) => V
>{ x: 1 } : { x: number; }
>x : number
>1 : 1
>{ x: 1, y: '' } : { x: number; y: string; }
>x : number
>1 : 1
>y : string
>'' : ""
>{ x: 2, y: 2, z: true } : { x: number; y: number; z: true; }
>x : number
>2 : 2
>y : number
>2 : 2
>z : true
>true : true
foo(a, b, a);
>foo(a, b, a) : A
>foo : <T, U, V>(x: T, y: U, z: V) => V
>a : A
>b : B
>a : A
foo(a, { foo: 1, bar: '', hm: true }, b);
>foo(a, { foo: 1, bar: '', hm: true }, b) : B
>foo : <T, U, V>(x: T, y: U, z: V) => V
>a : A
>{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: true; }
>foo : number
>1 : 1
>bar : string
>'' : ""
>hm : true
>true : true
>b : B
foo((x: number, y: string) => { }, (x, y: boolean) => { }, () => { });
>foo((x: number, y: string) => { }, (x, y: boolean) => { }, () => { }) : () => void
>foo : <T, U, V>(x: T, y: U, z: V) => V
>(x: number, y: string) => { } : (x: number, y: string) => void
>x : number
>y : string
>(x, y: boolean) => { } : (x: any, y: boolean) => void
>x : any
>y : boolean
>() => { } : () => void
function foo2<T extends A, U extends A, V extends A>(x: T, y: U, z: V): V { return z; }
>foo2 : <T extends A, U extends A, V extends A>(x: T, y: U, z: V) => V
>x : T
>y : U
>z : V
>z : V
//function foo2<T extends A, U extends T, V extends U>(x: T, y: U, z: V): V { return z; }
foo(b, a, c);
>foo(b, a, c) : C
>foo : <T, U, V>(x: T, y: U, z: V) => V
>b : B
>a : A
>c : C
foo(c, c, a);
>foo(c, c, a) : A
>foo : <T, U, V>(x: T, y: U, z: V) => V
>c : C
>c : C
>a : A
|