这直到昨天才有效,所以我相信 typescript 或 dhtmlxgantt 上发生了一些变化。
我在编译时遇到这些错误:
error TS2306: File 'projectPath/node_modules/@types/dhtmlxgantt/index.d.ts' is not a module.
src/app/shared/components/gantt/gantt.component.ts(11,17): error TS6137: Cannot import type declaration files. Consider importing 'dhtmlxgantt' instead of '@types/dhtmlxgantt'
我也尝试使用他们的演示代码并遇到相同的错误: https: //github.com/DHTMLX/angular2-gantt-demo
有没有人遇到过同样的问题并且可以阐明一些?
看起来 dhtmlx-gantt 的类型定义似乎与 typescript 2.9.1 不兼容(昨天发布https://github.com/Microsoft/TypeScript/releases/tag/v2.9.1)
dhtmlxGantt 的类型定义有一段时间没有更新,这是问题的主要原因。
作为目前可能的解决方法,您可以将项目中的打字稿降级到 2.8.x(我已经检查过构建似乎在 2.8.4 上运行)
npm uninstall typescript
npm install typescript@2.8.4
或者,在 package.json 中指定 typescript 版本
"typescript": "2.8.4",
如果无法降级,您可以删除 dhtmlx 甘特图的类型定义并手动声明甘特图实例:
declare let gantt: any;
显然,你会丢失类型信息,但它似乎仍然比无法编译的项目要好
此拉取请求更新了类型定义,值得赞扬https://github.com/duayres。
因此,这个问题现在应该得到解决
| 归档时间: |
|
| 查看次数: |
1881 次 |
| 最近记录: |