-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
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
Metadata
Metadata
Assignees
Labels
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases