Vaughan Hilts
Vaughan Hilts

Reputation: 2879

How can we use inheritance with the module system?

I have a single module and two classes:

module OpenORPG {

    export class MovementSystem extends GameSystem {
}

}


module OpenORPG {

    export class GameSystem {

        public parent: Zone;

}

}

They look something like that. This gets an error, as described in this issue: https://typescript.codeplex.com/workitem/627

This happens with modules, though. Can anyone comment on how getting these types of depedencies works? I just get a dreaded:

Uncaught TypeError: Cannot read property 'prototype' of undefined

Upvotes: 0

Views: 155

Answers (1)

basarat
basarat

Reputation: 276189

Even within the module you need to order the two properly i.e.

module OpenORPG {
    export class GameSystem {
        public parent: Zone;
    }
}

module OpenORPG {
    export class MovementSystem extends GameSystem {
}

Update: If you have this split in seperate file you can order the code generated from --out using a reference file that lists the files in order.

PS: grunt-ts can generate a reference file for you https://github.com/grunt-ts/grunt-ts#javascript-generation-and-ordering

Upvotes: 1

Related Questions