mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
fix: Object.groupBy
return type should be a partial (#21680)
Signed-off-by: Joel Walker <joelwalker1995@gmail.com>
This commit is contained in:
parent
f9df3833c7
commit
a267225a17
2 changed files with 7 additions and 1 deletions
|
@ -196,6 +196,12 @@ Deno.test(function objectGroupBy() {
|
|||
});
|
||||
});
|
||||
|
||||
Deno.test(function objectGroupByEmpty() {
|
||||
const empty: string[] = [];
|
||||
const result = Object.groupBy(empty, () => "abc");
|
||||
assertEquals(result.abc, undefined);
|
||||
});
|
||||
|
||||
// Taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy#examples
|
||||
Deno.test(function mapGroupBy() {
|
||||
const inventory = [
|
||||
|
|
2
cli/tsc/dts/lib.esnext.object.d.ts
vendored
2
cli/tsc/dts/lib.esnext.object.d.ts
vendored
|
@ -21,7 +21,7 @@ interface ObjectConstructor {
|
|||
groupBy<Item, Key extends PropertyKey>(
|
||||
items: Iterable<Item>,
|
||||
keySelector: (item: Item, index: number) => Key,
|
||||
): Record<Key, Item[]>;
|
||||
): Partial<Record<Key, Item[]>>;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
|
|
Loading…
Reference in a new issue