Open
Description
🔎 Search Terms
reverse mapped type inference inferred constraint union intersection
🕗 Version & Regression Information
- This is the behavior in every version I tried. However, I'd call this to only be a bug for recent 5.4 nightlies - this should only work since Reverse mapped types with intersection constraint #55811
⏯ Playground Link
💻 Code
declare function fn<T extends Record<string, number>>(obj: {
[K in (keyof T & "a") | "b"]: T[K];
}): T;
const obj = {
a: 42,
b: 100,
c: true,
};
const result = 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