diff --git a/types/d3-contour/d3-contour-tests.ts b/types/d3-contour/d3-contour-tests.ts index ce9d50717f..48f8508d01 100644 --- a/types/d3-contour/d3-contour-tests.ts +++ b/types/d3-contour/d3-contour-tests.ts @@ -113,7 +113,10 @@ interface CustomDatum { // Get contour generator ------------------------------------------------------- -const contDensDefault: d3Contour.ContourDensity<[number, number]> = d3Contour.contourDensity(); +// test generic parameter defaults for ContourDensity and contourDensity +const contDensDefault: d3Contour.ContourDensity = d3Contour.contourDensity(); +const contDensDefaultCopy: d3Contour.ContourDensity<[number, number]> = contDensDefault; +// test with explicit generic parameter let contDensCustom: d3Contour.ContourDensity = d3Contour.contourDensity(); // Configure contour generator ================================================= diff --git a/types/d3-contour/index.d.ts b/types/d3-contour/index.d.ts index ba9c8e075d..c0b3d70b5e 100644 --- a/types/d3-contour/index.d.ts +++ b/types/d3-contour/index.d.ts @@ -120,8 +120,13 @@ export function contours(): Contours; /** * A contour generator for density estimates. + * + * The generic refers to the data type of an element in the data array + * used with the density contour generator. If omitted, the default setting assumes that, + * the elements of the data array used with the density contour generator are two-element arrays. + * The first element corresponds to the x-dimension, the second to the y-dimension. */ -export interface ContourDensity { +export interface ContourDensity { /** * Estimates the density contours for the given array of data, returning an array of GeoJSON MultiPolygon geometry objects. * Each geometry object represents the area where the estimated number of points per square pixel is greater than or equal to @@ -238,21 +243,15 @@ export interface ContourDensity { bandwidth(bandwidth: number): this; } -/** - * Construct a new contour generator for density estimates with the default settings. - * - * The default settings assume that, the elements of the data array used - * with the density contour generator are two-element arrays. The first element - * corresponds to the x-dimension, the second to the y-dimension. - */ -export function contourDensity(): ContourDensity<[number, number]>; /** * Construct a new contour generator for density estimates. * * The generic refers to the data type of an element in the data array - * used with the density contour generator. + * used with the density contour generator. If omitted, the default setting assumes that, + * the elements of the data array used with the density contour generator are two-element arrays. + * The first element corresponds to the x-dimension, the second to the y-dimension. * * Important: ensure that the x- and y-accessor functions are configured to * match the data type used for the generic Datum. */ -export function contourDensity(): ContourDensity; +export function contourDensity(): ContourDensity;