* [fix](d3-format)
* Add apostrophe to permissible thousands separators to accomodate e.g. Switzerland, Liechtenstein
* [chore](d3) Pin down versions
* Added package.json to pin down the minor versions of the D3 modules forming part of the standard bundle
* The pinned major.minor versions correspond to D3 v4.2 of the standard bundle (patches are not pinnable, major version is too coarse)
* Changes tsconfig.json to used pinned dependencies
* Fixed tsconfig.json:
* Needed to leave type-resolution related options in the tsconfig.json. So that d3-test can find the d3 definition itself.
* packages in dependency are still used to pin down D3 modules
* Replace D3 v3 definition with D3 v4 (bundle)
* Replaces the legacy D3 v3 definitions in `d3` with a definition file representing the D3 version 4 standard bundle
* Add `package.json` file with legacy dependency to @types/d3 version >=3.5.36 <4.0.0
* Updated tsconfig.json, package.json, versions
* Updated tsconfig.json to control typings resolution for D3 v3
* Updated package.json to use caret notation of D3 typings
* Updated certain affected definitions header comments with version numbers, where version number was missing buit seemed reasonably ascertainable as latest.
* Added comments to each affected definition file with TODO once upgrade to D3 v4 is considered
* Chore changes as per review.
* Removed TODO "upgrade-to-v4" comments
* Removed added empty lines.
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]
Given `selection.datum((d,i,o) => 'string')`, TypeScript would always use the first overload, when it should be using the second. Correcting the order fixes this.
* Added empty() and size() methods to interface Enter<Datum>. As per D3 API these methods are defined on the enter selection.
* Added test function testEnterSizeEmpty() for .enter().empty() and .enter.size() methods.
The signature of Transition.styleTween is currently:
styleTween(name: string, tween: (datum: Datum, index: number, attr: string) => Primitive, priority?: string): Transition<Datum>; (line 833)
Note that the tween is said to return a Primitive. This seems incorrect, both in terms of D3 intent and implementation.
The *correct* version appears to be:
styleTween(name: string, tween: (datum: Datum, index: number, attr: string) => (t: number) => Primitive, priority?: string): Transition<Datum>;
(This is similar to similar to Transition.attrTween.)
First, the documentation states:
>>> The return value of tween must be an interpolator: a function that maps a parametric value t in the domain [0,1]
>>> to a color, number or arbitrary value.
Second, the source code of d3 3.5.5 has:
d3_transitionPrototype.styleTween = function(name, tween, priority) {
if (arguments.length < 3) priority = "";
function styleTween(d, i) {
var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name));
return f && function(t) {
this.style.setProperty(name, f(t), priority);
};
}
return this.tween("style." + name, styleTween);
};
Note the line "this.style.setProperty(name, f(t), priority);" where the result f of applying the tween is passed a parameter t.
The only point of discussion might be the type of the return value of the tween's interpolator output. Is it Primitive or any? The documentation quoted above (incidentally the same for attrTween and styleTween) explicitly allows for an arbitrary value. I don't have enough D3 experience to know if this is a practically relevant possibility.
Many thanks for your great work on d3.d.ts!!! Especially the use of tweens and interpolators perfectly illustrates the benefits of Typescript.
Best wishes,
Matthias