I installed the popular library d3through NPM.
npm install d3
tsd install d3 -save
tsc
In my file, home.tsI imported the module:
import * as d3 from 'd3/d3';
It compiles correctly, but I get this semantic error:
app/home/components/home.ts(2,21): error TS2307: Cannot find module 'd3/d3'.
Also, I am losing all my syntax highlighting / input start information in my IDE.
The original d3.d.tsfile provided TSDdeclares the module as follows:
declare module 'd3' {
export = d3;
}
If I change the module to 'd3/d3', everything will be fine:
declare module 'd3/d3' {
export = d3;
}
So, it’s hard for me to find what I need:
import * as d3 from 'd3';gives me definitions of the types that I expect, but is looking for a module in node_modules/d3.jswhich is incorrect.
import * as d3 from 'd3/d3'; , , , .
, , ?
FYI: typescript 1.7.5, moduleResolution node.