React / Typescript Ag-grid

时间:2016-09-14 12:29:05

标签: reactjs typescript systemjs ag-grid

我试图在我的应用程序中使用ag-grid with react和typescript。 ag-grid .d.ts文件在项目内部,所以我无法安装,然后使用typings install --save ...

问题是当我尝试导入它时......

W

我正在使用VSCode ...它显示我" [ts]找不到模块",同时编译相同的东西。

有关该应用程序的更多信息: 的 tsconfig.json

import { AgGridReact } from 'ag-grid-react';

typings.json

{
    "compileOnSave": false,
    "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": false,
        "removeComments": false,
        "sourceMap": false,
        "target": "es5",
        "module": "system",
        "jsx": "react"
    }
}

最后我试着在我的打字文件中包含引用 的 index.d.ts

{
  "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"
  }
}

1 个答案:

答案 0 :(得分:0)

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",
    "ag-grid": "13.1.x",
    "ag-grid-react": "13.1.x"
  }
}

一旦包含了这两个依赖项,请转到root包文件夹并从那里打开命令提示符。在命令提示符下输入npm install。它应该安装ag-grid依赖项。