score:0

I do import * as D3 from 'd3'; in my custom area-cart.component.ts, and no complains from compiler.

In package.json I have:

"@types/d3": "^3.5.38",
"d3": "^3.5.17",

Version 3 seems working fine. Do you really need D3 v4?

score:0

You can try:

import * as d3selection from 'd3-selection';
import 'd3-transition';

d3selection.select(...)

score:2

You're using v4.2.x of d3 but the typings are for v3.5.x. Refer to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11367 for an explanation about why the default version is 3.x.

This D3 Standard bundle is published as a UMD module of name d3. Currently, the definitions for this standard bundle cannot be published in DefinitelyTyped/types-2.0 (see closed PR #10453) due to existing dependencies of other libraries on the legacy D3 v3.x definitions (e.g. plottable, nvd3) contained in the same directory.

With the sincerest hope that it remains a temporary workaround, developers who need a definition file representing the D3 version 4 may proceed as follows:

Install the module-level definitions for the D3 modules comprising the D3 standard bundle individually, using e.g. npm install @types/d3-selection --save

Alternatively, if it works for your use case you could try angular2 d3 service: https://github.com/tomwanzek/d3-ng2-service


Related Query