Rodrigo
Rodrigo

Reputation: 3278

dhtmlxscheduler with Aurelia and typescript

I'm trying to install dhtmlxscheduler to my Aurelia CLI (typescript) app. I've npm installed it:

npm i dhtmlx-scheduler

Then I added it to the aurelia.json file:

{
  "name": "dhtmlx-scheduler",
  "path": "../node_modules/dhtmlx-scheduler/codebase",
  "main": "dhtmlxscheduler"
},

And created the global typings for it:

typings install dt~dhtmlxscheduler --global --save

everything installed and au run compiles correctly. When I try to actually use the the library though I get this error:

error TS2307: Cannot find module 'dhtmlxscheduler'.
[02:00:15] gulp-notify: [Error running Gulp] Error: src/components/appointments/appointments.ts(2,20): error TS2307: Cannot find module 'dhtmlxscheduler'.

I'm importing it like so:

import * as scheduler from 'dhtmlxscheduler';

Upvotes: 3

Views: 571

Answers (2)

loaded02
loaded02

Reputation: 251

It works with the import statement from @Robinson Collado. You might want to add the dhtmlx-gantt css file as resource:

{
  "name": "dhtmlx-gantt",
  "path": "../node_modules/dhtmlx-gantt/codebase",
  "main": "dhtmlxgantt",
  "resources": [
    "dhtmlxgantt.css"
  ]
}

and include it in your template:

<require from="dhtmlx-gantt/dhtmlxgantt.css"></require>

Upvotes: 1

Robinson Collado
Robinson Collado

Reputation: 316

I looked into dhtmlxscheduler.js and it doesn't export any member properties. Doing import * as scheduler from 'dhtmlxscheduler'; should give you an error.

Instead, import the entire module:

import 'dhtmlx-scheduler'; // Taking into account the comment that I left above

Then you can call the scheduler function directly in your class.

Upvotes: 0

Related Questions