2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction3.ts ===
|
|
|
|
// satisfaction of a constraint to Function, no errors expected
|
|
|
|
|
|
|
|
function foo<T extends (x: string) => string>(x: T): T { return x; }
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>T : T
|
|
|
|
>x : string
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
|
|
|
|
interface I {
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
(): string;
|
|
|
|
}
|
|
|
|
var i: I;
|
|
|
|
>i : I
|
|
|
|
>I : I
|
|
|
|
|
|
|
|
class C {
|
|
|
|
>C : C
|
|
|
|
|
|
|
|
foo: string;
|
|
|
|
>foo : string
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: { (): string };
|
|
|
|
>a : () => string
|
|
|
|
|
|
|
|
var b: { new (): string };
|
|
|
|
>b : new () => string
|
|
|
|
|
|
|
|
var c: { (): string; (x): string };
|
|
|
|
>c : { (): string; (x: any): string; }
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
var r1 = foo((x) => x);
|
|
|
|
>r1 : (x: any) => any
|
|
|
|
>foo((x) => x) : (x: any) => any
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>(x) => x : (x: any) => any
|
|
|
|
>x : any
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
var r2 = foo((x: string) => x);
|
|
|
|
>r2 : (x: string) => string
|
|
|
|
>foo((x: string) => x) : (x: string) => string
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>(x: string) => x : (x: string) => string
|
|
|
|
>x : string
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
var r3 = foo(function (x) { return x });
|
|
|
|
>r3 : (x: any) => any
|
|
|
|
>foo(function (x) { return x }) : (x: any) => any
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>function (x) { return x } : (x: any) => any
|
|
|
|
>x : any
|
|
|
|
>x : any
|
|
|
|
|
|
|
|
var r4 = foo(function (x: string) { return x });
|
|
|
|
>r4 : (x: string) => string
|
|
|
|
>foo(function (x: string) { return x }) : (x: string) => string
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>function (x: string) { return x } : (x: string) => string
|
|
|
|
>x : string
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
var r5 = foo(i);
|
|
|
|
>r5 : I
|
|
|
|
>foo(i) : I
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>i : I
|
|
|
|
|
|
|
|
var r8 = foo(c);
|
|
|
|
>r8 : { (): string; (x: any): string; }
|
|
|
|
>foo(c) : { (): string; (x: any): string; }
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>c : { (): string; (x: any): string; }
|
|
|
|
|
|
|
|
interface I2<T> {
|
|
|
|
>I2 : I2<T>
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
(x: T): T;
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
var i2: I2<string>;
|
|
|
|
>i2 : I2<string>
|
2014-08-19 04:56:03 +02:00
|
|
|
>I2 : I2<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
class C2<T> {
|
|
|
|
>C2 : C2<T>
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
foo: T;
|
|
|
|
>foo : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
|
|
|
|
var a2: { <T>(x: T): T };
|
|
|
|
>a2 : <T>(x: T) => T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var b2: { new <T>(x: T): T };
|
|
|
|
>b2 : new <T>(x: T) => T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var c2: { <T>(x: T): T; <T>(x: T, y: T): T };
|
|
|
|
>c2 : { <T>(x: T): T; <T>(x: T, y: T): T; }
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
>x : T
|
|
|
|
>T : T
|
|
|
|
>y : T
|
|
|
|
>T : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var r9 = foo(function <U>(x: U) { return x; });
|
|
|
|
>r9 : <U>(x: U) => U
|
|
|
|
>foo(function <U>(x: U) { return x; }) : <U>(x: U) => U
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>function <U>(x: U) { return x; } : <U>(x: U) => U
|
|
|
|
>U : U
|
|
|
|
>x : U
|
|
|
|
>U : U
|
|
|
|
>x : U
|
|
|
|
|
|
|
|
var r10 = foo(<U extends string>(x: U) => x);
|
|
|
|
>r10 : <U extends string>(x: U) => U
|
|
|
|
>foo(<U extends string>(x: U) => x) : <U extends string>(x: U) => U
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
><U extends string>(x: U) => x : <U extends string>(x: U) => U
|
|
|
|
>U : U
|
|
|
|
>x : U
|
|
|
|
>U : U
|
|
|
|
>x : U
|
|
|
|
|
|
|
|
var r12 = foo(i2);
|
|
|
|
>r12 : I2<string>
|
|
|
|
>foo(i2) : I2<string>
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>i2 : I2<string>
|
|
|
|
|
|
|
|
var r15 = foo(c2);
|
|
|
|
>r15 : { <T>(x: T): T; <T>(x: T, y: T): T; }
|
|
|
|
>foo(c2) : { <T>(x: T): T; <T>(x: T, y: T): T; }
|
|
|
|
>foo : <T extends (x: string) => string>(x: T) => T
|
|
|
|
>c2 : { <T>(x: T): T; <T>(x: T, y: T): T; }
|
|
|
|
|