I'm using angular-cli which uses webpack under the hood in a project with TypeScript. Have to upgrade legacy d3 v3 to v4 and I'd like to keep all uses of .attr({ ... an object ... }) by changing it to .attrs().
I added d3-selection-multi (and @types/...). It compiles without error but when .attrs() is called there is an error.
My import:
import * as d3 from 'd3';
import 'd3-selection-multi';
d3-selection-multi just adds some methods to prototypes of objects of standard d3. Here is the source.
My code (not very important IMO):
bars.exit()
.transition()
.duration(duration)
.ease(ease)
.attrs(removeAttrs) // <--
.remove();
The error:
bars.exit(...).transition(...).duration(...).ease(...).attrs is not a function
I'm using angular-cli 1.0.0-beta.19-3 'plain vanilla' (without any tweaks).
What's wrong?
Before marking this question as duplicate: I'm not using System.js and not jspm. The other posts and answers didn't help.
npm install @types/d3-selection-multi d3-selection-multi? Can you then compiled3.select('svg').attrs({})? I doubt.attrsis not found.package.jsonI cannot tell. Also angular-cli is a complex beast and Beta.14 now runs on Webpack.