How to use CreateJS on Typescript

This post will be small, but I spent some hours trying to find out how to use the createJS classes in TypeScript, so I think it is worth sharing. The below example is for importing easelJS.

The problem of using createJS in TypeScript is that it doesn’t export modules but just the namespace. In that sense, doing the usual stuff won’t work:

import * as createjs from 'createjs';


To import a namespace one should put on the top of the TypeScript file a reference as a comment:

/// <reference path="../../node_modules/@types/easeljs/index.d.ts" />


After doing it all createJS classes can be accessed via the namespace createjs, for example:

var shape = new createjs.Shape();


Of course for all this to work, the typescript definitions must be imported or generated. I used the definitions from DefinitelyTyped which can be installed via npm:

npm install --save @types/easeljs



That’s it. I hope this post saves you time.

Leave a comment

Your email address will not be published. Required fields are marked *