es-toolkit icon indicating copy to clipboard operation
es-toolkit copied to clipboard

fix(groupBy): Use more accurate return type

Open the5thbeatle opened this issue 1 month ago • 1 comments

Summary

Updates the return type of groupBy to reflect that properties need not exist in the output but that if they do, their value has at least length 1. It prevents users from having to suppress unnecessary condition warnings when trying to safely access properties in groupBy results.

Changes

  • Wraps groupBy return type with Partial
  • Changes values in groupBy return type from T[] to [T, ...T[]]

Comments

The compat function is still using Record type here instead of Partial<Record>

the5thbeatle avatar Oct 16 '25 04:10 the5thbeatle