Microsoft/TypeScript
View on GitHubType parameter leak caused by `this` and reverse mapped type
Open
#62779 opened on Nov 18, 2025
BugDomain: This-TypingHelp Wanted
Description
🔎 Search Terms
type parameter leak reverse mapped type type variable this
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
declare function test<T extends Record<string, unknown>>(obj: {
[K in keyof T]: () => T[K];
}): T;
const obj = test({
// ^? const obj: { a: number; b: T[string]; }
a() {
return 0;
},
b() {
return this.a();
},
});
🙁 Actual behavior
obj's type refers to T[string]
🙂 Expected behavior
T definitely shouldn't leak into obj's type
Additional information about the issue
No response