I have an Angular 2 project (this is a Quick Start project for simplicity) and I am importing a version of d3.js 4. There is no TypeScript definition with d3, as this is only javascript.
In index.html, I add lib:
<script src="https://d3js.org/d3.v4.min.js"></script>
In TypeScript app.component.ts, I refer to d3.select () .... and it works fine - draws a circle:
d3.select("body").append("svg").attr("width", 50).attr("height", 50).append("circle").attr("cx", 25).attr("cy", 25).attr("r", 25).style("fill", "purple");
Visual Studio code does not recognize d3, so I set the identifiers from DefinitelyTyped - then the IDE recognizes d3, and I get code completion, etc.:
typings install dt~d3
Now I tried a second project, but the route has gone npm, npm install --save d3and I can refer to d3.js through node_modules in the index.html, using
<script src="node_modules/d3/build/d3.min.js"></script>
, npm ? d3 component.ts, . , - ?