This project is read-only.

Error "Define is not defined"

Topics: General
Feb 17, 2014 at 11:42 AM
Edited Feb 17, 2014 at 11:43 AM
I created a GameModule.ts with the following code:

export module Game1 {
export class Game2{

    public draw() {

and inside the app.ts I call this module like following:

/// <reference path="GameModule.ts" />
import GameModule = require("GameModule");

var g = new GameModule.Game1.Game2();

code compiles without any error, but it will throw exception in browser with following details:

"ReferenceError: define is not defined"

I'm using Visual Studio 2013 Ultimate, Typescript version 0.9.5 and Web Essentials 2013 version 1.8.5.

Any help is really appreciated.
Feb 17, 2014 at 3:22 PM
If you're going to use import you will need an AMD loader.

If you're going to include the script in the browser yourself then simply drop the import statement.
You'll also need to remove the export from module Game1.

Basically you need to understand how internal and external modules work.

Here is a short and sweet introduction that I found:
Feb 18, 2014 at 5:51 PM
Hi nabog

Thank you for your reply.
As you said I removed export from module Game1 and dropped the import statement but now at the run time I catch the following error:

"ReferenceError: Game1 is not defined".

Here is the code of "Game1.ts".
module Game1 {
export class Game2 {
    constructor() {

    public draw() {

And here is the code of "app.ts":

/// <reference path="Game1.ts" />
window.onload = () => {
 var g = new Game1.Game2();

Both type script files are located at the root of the project. I don't now what is wrong with it. Am I miss anything else????
Feb 18, 2014 at 6:14 PM
Your HTML page needs to actually load both .js files through script tags; simply having the script files in the project will not cause them to be loaded in the browser.