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]
This commit is contained in:
James McCallum
2015-12-27 15:23:05 -08:00
committed by Leon Radley
parent 2144c0801e
commit 6429513724

5
d3/d3.d.ts vendored
View File

@@ -1078,6 +1078,11 @@ declare namespace d3 {
* Return the min and max simultaneously.
*/
export function extent<T>(array: T[], accessor: (datum: T, index: number) => string): [string, string];
/**
* Return the min and max simultaneously.
*/
export function extent<T>(array: T[], accessor: (datum: T, index: number) => Date): [Date, Date];
/**
* Return the min and max simultaneously.