Microsoft/TypeScript
GitHub ã§èŠãType parameter leak caused by `this` and reverse mapped type
Open
#62,779 opened on 2025幎11æ18æ¥
BugDomain: This-TypingHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð 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