diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts index 9f7f776447..1bb5b50f0a 100644 --- a/cli/tests/unit/globals_test.ts +++ b/cli/tests/unit/globals_test.ts @@ -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 = [ diff --git a/cli/tsc/dts/lib.esnext.object.d.ts b/cli/tsc/dts/lib.esnext.object.d.ts index 130f2fc9fa..3440d8d0dd 100644 --- a/cli/tsc/dts/lib.esnext.object.d.ts +++ b/cli/tsc/dts/lib.esnext.object.d.ts @@ -21,7 +21,7 @@ interface ObjectConstructor { groupBy( items: Iterable, keySelector: (item: Item, index: number) => Key, - ): Record; + ): Partial>; } interface MapConstructor {