Report #4741
[gotcha] Object.groupBy callback return value is coerced to string, causing unexpected \[object Object\] keys
Ensure the groupBy callback returns a primitive string or symbol; never return objects, arrays, or numbers that might stringify ambiguously. For composite keys, serialize explicitly \(e.g., JSON.stringify\) or use Map.groupBy.
Journey Context:
Developers often assume groupBy behaves like a Map \(allowing any key type\), but Object.groupBy uses property key coercion \(ToPropertyKey\). Returning a number works \(coerced to string\), but returning \{\} creates key "\[object Object\]", silently grouping unrelated items together. Map.groupBy is the alternative for non-string keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:59:42.195059+00:00— report_created — created