-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Milestone
Description
🔎 Search Terms
overlaod union
🕗 Version & Regression Information
This changed between versions ______ and _______This changed in commit or PR _______- This is the behavior in every version I tried, and I reviewed the FAQ for entries about overload
I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
function groupBy<T>(array: Array<T>| ReadonlyArray<T>, key: any): Map<any, Array<T>> {
return array.reduce<Map<any, Array<T>>>((acc, element) => {
const k = typeof key === 'function' ? (key as (element: T) => any)(element) : element[key as keyof T];
let group = acc.get(k);
if (!group) {
acc.set(k, group = []);
}
group.push(element);
return acc;
}, new Map<any, Array<T>>());
}
🙁 Actual behavior
getting the errors:
Expected 0 type arguments, but got 1.
Type 'T' is not assignable to type 'Map<any, T[]>'.
Expected 0 type arguments, but got 1.
Property 'get' does not exist on type 'T'.
Property 'set' does not exist on type 'T'.
🙂 Expected behavior
Allowing the use of the 3rd overload method reduce<U>
of Array
/ ReadonlyArray
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.