How do I import Excalibur as a Typescript module?

140 views
Skip to first unread message

Shu Sam Chen

unread,
Nov 16, 2016, 6:32:00 AM11/16/16
to excaliburjs
The "normal" way of importing excalibur seems to be by including it in a webpage. However, when I try to import it in the standard typescript method(s) i.e.:

import * as ex from "excalibur";

or

import ex = require("excalibur");

The Typescript compiler gives an error. This isn't because it can't find the d.ts file - it can. Instead, the error given is "error TS2306: File '.../node_modules/excalibur/dist/excalibur.d.ts' is not a module."

This seems to indicate that the d.ts file is not a valid Typescript module, for one of a variety of reasons. Does anyone have any experience trying to do the above?

Kamran Ayub

unread,
Nov 16, 2016, 8:32:30 AM11/16/16
to excaliburjs
Hi Shu! We have been getting this question quite a bit, it is probably time to add something to our Docs about it but we plan to address this in the next release. In the meantime, you can add a line to your excalibur.d.ts file to make TS happy, see this other thread related to Angular 2:

Shu Sam Chen

unread,
Nov 16, 2016, 11:30:39 AM11/16/16
to excaliburjs
That seems to have fixed it. Thanks for the reply!
Reply all
Reply to author
Forward
0 new messages