Roger Alsing Roger Alsing - 2 months ago 11
TypeScript Question

How do I import other TypeScript files?

When using the TypeScript plugin for, how do I make one TypeScript file import modules declared in other TypeScript files?

file 1:

module moo
export class foo .....

file 2:

//what goes here?

class bar extends


You need to reference the file on the top of the current file.

You can do this like this:

/// <reference path="../typings/jquery.d.ts"/>
/// <reference path="components/someclass.ts"/>

class Foo { }


These paths are relative to the current file.

Your example:

/// <reference path="moo.ts"/>

class bar extends

UPDATE: From TypeScript version 1.5 you can use tsconfig.json:

It completely eliminates the need of the comment style referencing.