From 64295137243573d3f7b9a0dffa7390d0b8c241ba Mon Sep 17 00:00:00 2001 From: James McCallum Date: Sun, 27 Dec 2015 15:23:05 -0800 Subject: [PATCH 1/2] Updated extent - added [Date, Date] return type The interfaces for extent don't seem to cover the common date extent scenario - I can see there's one covering generics with a generic argument accessor but it's return type is still limited to 'primitive' (toString()-able) or the original object type 'U' - not a date typed property of U. In any case the standard x.domain(d3.extent(data, d=> d.date)) where data is an array of objects currently gives type errors in typescript - maybe this fix is a very specific case and there's a better generic way to approach, but I can see there are already dedicated overloads for [number, number] and [string, string] --- d3/d3.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index b35d898522..3f07ff6129 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1078,6 +1078,11 @@ declare namespace d3 { * Return the min and max simultaneously. */ export function extent(array: T[], accessor: (datum: T, index: number) => string): [string, string]; + + /** + * Return the min and max simultaneously. + */ + export function extent(array: T[], accessor: (datum: T, index: number) => Date): [Date, Date]; /** * Return the min and max simultaneously. From 626e4aa1e48091285b6c9bdf2c893599e43f5b4b Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Wed, 22 Jun 2016 07:19:22 +0200 Subject: [PATCH 2/2] d3 extent should take array T, not array U --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 3f07ff6129..1da10a78ab 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1087,7 +1087,7 @@ declare namespace d3 { /** * Return the min and max simultaneously. */ - export function extent(array: U[], accessor: (datum: T, index: number) => U): [U | Primitive, U | Primitive]; + export function extent(array: T[], accessor: (datum: T, index: number) => U): [U | Primitive, U | Primitive]; /** * Compute the sum of an array of numbers.