【发布时间】:2016-12-15 16:26:21
【问题描述】:
我对打字稿很陌生。我使用 Visual Studio Code 作为我的编辑器并使用 gulp 来执行打字稿。我希望在我的打字稿代码中使用 d3。我使用以下安装了 d3,
npm install d3
typings install d3 --save
下面是我的 package.json
{
"name": "proj",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-typescript": "^3.1.3",
"typescript": "^2.1.4"
}
}
typings.json
{
"dependencies": {
"d3": "registry:npm/d3#3.0.0+20160723033700"
}
}
tsconfig.json
{
"files": [
"src/main.ts",
"src/greet.ts"
],
"compilerOptions": {
"noImplicitAny": true,
"target": "es5"
}
}
当我现在在我的 TS 代码中导入 d3 时,如下所示,
import * as d3 from "d3";
它给了我以下错误
[ts] 找不到模块“d3”的声明文件。 'c:/.../VS/proj/node_modules/d3/build/d3.node.js' 隐含一个 'any' 类型
谁能告诉我我做错了什么
谢谢!
【问题讨论】:
标签: d3.js typescript