🔎 Search Terms
reverse mapped type inference inferred constraint union intersection
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20231231#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVNQB4AVeEADwxFWAGd4AlcHGYQ2jGLVAcwBp4qZAFsARiBgA+SQAocogFYAueAG8AUPHgBtANLxu8GQGsQATxyJ4pAGTwARFHsBKeAB8Ho+wF0VxPd4A3OoAvs5+wWB4HPDyCvAAvGqa8FAqACwATHwpoioAjAAMhTlaYCqcyCA5IZHRGPBwtMgQDUmIqHKKzsEA9L1aWgB6APzqQA
💻 Code
declarefunctionfn<TextendsRecord<string,number>>(obj: {[Kin(keyofT&"a")|"b"]: T[K];}): T;constobj={a: 42,b: 100,c: true,};constresult=fn(obj);🙁 Actual behavior
It fails to infer T and uses its constraint
🙂 Expected behavior
It should infer { a: number; b: number; }
Additional information about the issue
No response
🔎 Search Terms
reverse mapped type inference inferred constraint union intersection
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20231231#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVNQB4AVeEADwxFWAGd4AlcHGYQ2jGLVAcwBp4qZAFsARiBgA+SQAocogFYAueAG8AUPHgBtANLxu8GQGsQATxyJ4pAGTwARFHsBKeAB8Ho+wF0VxPd4A3OoAvs5+wWB4HPDyCvAAvGqa8FAqACwATHwpoioAjAAMhTlaYCqcyCA5IZHRGPBwtMgQDUmIqHKKzsEA9L1aWgB6APzqQA
💻 Code
🙁 Actual behavior
It fails to infer
Tand uses its constraint🙂 Expected behavior
It should infer
{ a: number; b: number; }Additional information about the issue
No response