1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
//// [tests/cases/compiler/genericTypeWithCallableMembers2.ts] ////
=== genericTypeWithCallableMembers2.ts ===
function foo1<T extends { (): string; }>(f: T) {
>foo1 : <T extends () => string>(f: T) => string
>f : T
return f(); // should return 'string', once returned 'any'
>f() : string
>f : T
}
function foo2<T extends { new (): string; }>(f: T) {
>foo2 : <T extends new () => string>(f: T) => string
>f : T
return new f(); // should be legal, once was an error
>new f() : string
>f : T
}
|