124 lines
2.6 KiB
Text
124 lines
2.6 KiB
Text
|
=== 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 }
|
||
|
>A : A
|
||
|
>foo : number
|
||
|
|
||
|
interface B extends A { bar: string; }
|
||
|
>B : B
|
||
|
>A : A
|
||
|
>bar : string
|
||
|
|
||
|
interface C extends B { baz: boolean; }
|
||
|
>C : C
|
||
|
>B : B
|
||
|
>baz : boolean
|
||
|
|
||
|
var a: A;
|
||
|
>a : A
|
||
|
>A : A
|
||
|
|
||
|
var b: B;
|
||
|
>b : B
|
||
|
>B : B
|
||
|
|
||
|
var c: C;
|
||
|
>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
|
||
|
>T : T
|
||
|
>U : U
|
||
|
>V : V
|
||
|
>x : T
|
||
|
>T : T
|
||
|
>y : U
|
||
|
>U : U
|
||
|
>z : V
|
||
|
>V : V
|
||
|
>V : 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, '') : string
|
||
|
>foo : <T, U, V>(x: T, y: U, z: V) => V
|
||
|
|
||
|
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
|
||
|
>{ x: 1, y: '' } : { x: number; y: string; }
|
||
|
>x : number
|
||
|
>y : string
|
||
|
>{ x: 2, y: 2, z: true } : { x: number; y: number; z: boolean; }
|
||
|
>x : number
|
||
|
>y : number
|
||
|
>z : boolean
|
||
|
|
||
|
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: boolean; }
|
||
|
>foo : number
|
||
|
>bar : string
|
||
|
>hm : boolean
|
||
|
>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
|
||
|
>T : T
|
||
|
>A : A
|
||
|
>U : U
|
||
|
>A : A
|
||
|
>V : V
|
||
|
>A : A
|
||
|
>x : T
|
||
|
>T : T
|
||
|
>y : U
|
||
|
>U : U
|
||
|
>z : V
|
||
|
>V : V
|
||
|
>V : 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
|
||
|
|