DHTMLX 甘特图 - 错误 TS6137:无法导入类型声明文件
DHTMLX gantt - error TS6137: Cannot import type declaration files
这在昨天之前一直有效,所以我相信打字稿或 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": "2.8.4",
如果降级不是一个选项,您可以删除 dhtmlx 甘特图的类型定义并手动声明甘特图实例:
declare let gantt: any;
显然,你会丢失类型信息,但它似乎仍然比不会编译的项目要好
更新
此 pull request, kudos to https://github.com/duayres 更新了类型定义。
因此,现在应该解决这个问题
这在昨天之前一直有效,所以我相信打字稿或 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": "2.8.4",
如果降级不是一个选项,您可以删除 dhtmlx 甘特图的类型定义并手动声明甘特图实例:
declare let gantt: any;
显然,你会丢失类型信息,但它似乎仍然比不会编译的项目要好
更新
此 pull request, kudos to https://github.com/duayres 更新了类型定义。
因此,现在应该解决这个问题