Closed

Description
TypeScript Version: nightly
Code
function f<T>(x: T, f: (x: T) => string): void {}
f("", x => x);
function g<T>(x: T, f: (this: T) => string): void {}
g<string>("", function() { return this; });
g("", function() { return this; });
Expected behavior:
No error. this
is always of type string
.
Actual behavior:
In the last line, the type of this
is still T
; it hasn't been 'filled in'.
src/a.ts(6,7): error TS2345: Argument of type '() => T' is not assignable to parameter of type '(this: string) => string'.
Type 'T' is not assignable to type 'string'.