TypeScript casting with modules

How can I cast the type of a variable with an exported class? Such as this:

GameManager.ts:

export class GameManager {}

Player.ts:

private _manager: GameManager;

when i use a /// <reference path="GameManager.ts" />, i get an error saying GameManager is out of scope or something like that. How does this work exactly?

There are several cases here, depending on where the export class GameManager {} line is:

Option 1: You're using "external" modules (i.e. you have any export declarations at top-level).

In this case, you should remove the reference tag and instead write:

import Manager = module("GameManager"); // N.B. this is the filename, not the class name
...
private _manager: Manager.GameManager;

Option 2: You're using "internal" modules (i.e. your export class is inside a module block, but not an export module block)

In that case, you should keep your /// <reference... tag and write:

private _manager: MyGame.Manager; // N.B. Assuming here that 'GameManager' lives inside 'module MyGame { ... }'

It might be that you don't actually want the export keyword on your class - if you do that, you don't need to qualify it at all (assuming there's nothing else at top-level being exported).

For an internal module you have to wrap the exported class in a module, so the GameManager.ts file should be:

module Game
{
    export class GameManager{}
}

Now you can access the GameManager class through

Game.GameManager