From b27c0cf67a99e01909d042aaa308d2300d9b74d1 Mon Sep 17 00:00:00 2001 From: TijmenW Date: Mon, 8 Jul 2019 23:03:02 +0200 Subject: [PATCH] [Crossfilter] Change return type of group.all() to a readonly array (#36707) * Change return type of group.all() to a readonly array * Added a test * Hopefully fix tests --- types/crossfilter/crossfilter-tests.ts | 10 +++++++--- types/crossfilter/index.d.ts | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/crossfilter/crossfilter-tests.ts b/types/crossfilter/crossfilter-tests.ts index e96d83a7e2..78dfdab696 100644 --- a/types/crossfilter/crossfilter-tests.ts +++ b/types/crossfilter/crossfilter-tests.ts @@ -62,9 +62,7 @@ var paymentGroupsByTotal = paymentsByTotal.group(total => Math.floor(total / 100 paymentGroupsByTotal.size(); -// bug of TS 0.9.5 https://typescript.codeplex.com/discussions/471751 -//paymentGroupsByTotal.reduce((p, v) => p + 1, (p, v) => p - 1, () => 0); -paymentGroupsByTotal.reduce((p, v) => p + 1, (p, v) => p - 1, () => 0); +paymentGroupsByTotal.reduce((p, v) => p + 1, (p, v) => p - 1, () => 0); paymentGroupsByTotal.reduceCount(); @@ -115,6 +113,12 @@ topTypes[0].value; // the count of payments of that type (e.g., 8) var types = paymentCountByType.all(); +// $ExpectError +types.sort(); + +types[0].key; +types[0].value; + paymentsByTotal.dispose(); crossfilter.bisect([], null, 0, 0); diff --git a/types/crossfilter/index.d.ts b/types/crossfilter/index.d.ts index bae8a06565..918d9771a9 100644 --- a/types/crossfilter/index.d.ts +++ b/types/crossfilter/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for CrossFilter // Project: https://github.com/square/crossfilter -// Definitions by: Schmulik Raskin , Izaak Baker , Einar Norðfjörð +// Definitions by: Schmulik Raskin , Izaak Baker , Einar Norðfjörð , Tijmen Wildervanck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace CrossFilter { @@ -73,7 +73,7 @@ declare namespace CrossFilter { export interface Group { top(k: number): Grouping[]; - all(): Grouping[]; + all(): ReadonlyArray>; reduce(add: (p: TGroup, v: T) => TGroup, remove: (p: TGroup, v: T) => TGroup, initial: () => TGroup): Group; reduceCount(): Group; reduceSum(value: (data: T) => TGroup): Group;