Search code examples
angulardhtmlx

DHTMLX gantt - error TS6137: Cannot import type declaration files


This was working until yesterday, so I believe something changed either on typescript or dhtmlxgantt.

I am getting these errors on compilation:

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'

I also tried with their demo code and had the same error: https://github.com/DHTMLX/angular2-gantt-demo

Has anyone experienced the same problem and can shed some light?


Solution

  • Looks like the type definitions of dhtmlx-gantt appears to be not compatible with typescript 2.9.1 (released yesterday https://github.com/Microsoft/TypeScript/releases/tag/v2.9.1 )

    The type definitions of dhtmlxGantt haven't been updated in a while, which is a main reason of the problem.

    As a possible workaround for now, you can either downgrade the typescript in your project to 2.8.x (I've checked the build seems to be working on 2.8.4)

    or, specify the typescript version in package.json "typescript": "2.8.4",

    If downgrading is not an option, you can remove type definitions of dhtmlx gantt and declare gantt instance manually: declare let gantt: any;

    obviously, you'll lose the type info, but it still seems to be better than the project that won't compile

    UPDATE

    Type definitions were updated by this pull request, kudos to https://github.com/duayres.

    Thus, this problem should be fixed now