我正试图在我的应用程序中使用ag-grid with react和typescript . ag-grid .d.ts文件在项目内部,所以我无法安装然后使用typings install --save ...
问题是当我尝试导入它时......
import { AgGridReact } from 'ag-grid-react';
我正在使用VSCode ...它向我显示“[ts]找不到模块”,同时编译同样的东西 .
有关该应用的更多信息: tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": false,
"removeComments": false,
"sourceMap": false,
"target": "es5",
"module": "system",
"jsx": "react"
}
}
typings.json
{
"name": "focco-sys-jspm",
"dependencies": {
"react": "registry:npm/react#15.0.1+20160601175240",
"react-addons-update": "registry:npm/react-addons-update#0.14.0+20160324044346",
"react-dom": "registry:npm/react-dom#15.0.1+20160705210405",
"react-router": "registry:npm/react-router#2.4.0+20160811060709"
}
}
最后我试着在我的打字文件中包含引用 index.d.ts
/// <reference path="modules/react-addons-update/index.d.ts" />
/// <reference path="modules/react-dom/index.d.ts" />
/// <reference path="modules/react-router/index.d.ts" />
/// <reference path="modules/react/index.d.ts" />
/// <reference path="../jspm_packages/npm/ag-grid@5.4.0/main.d.ts" />
/// <reference path="../jspm_packages/npm/ag-grid-react@5.4.0/main.d.ts" />
1 回答
将您的
typings.json
更改为一旦包含这两个依赖项,请转到root包文件夹并从那里打开命令提示符 . 在命令提示符下输入
npm install
. 它应该安装ag-grid
依赖项 .