Pavel Stupka
Pavel Stupka

Reputation: 213

TypeScript modules referencing

Have a look at the following TypeScript code:

module events {
    export class Event {
    }
}

module display.events {
    export class DisplayEvent extends events.Event {
    }
}

Basically, the idea is that DisplayEvent class from the module display.events is a descendant of Event class from the module events. There is however a problem with a naming of the modules thus the compiler searches for the Event class is display.events module:

error TS2094: The property 'Event' does not exist on value of type 'events'.

Is here any way to make the compiler (version 0.9.1.1) understand the structure of the modules?

Upvotes: 0

Views: 123

Answers (2)

Ryan Cavanaugh
Ryan Cavanaugh

Reputation: 220904

There isn't currently a way to do this without restructuring the names of the objects. It's basically a runtime problem -- the variables are lexically scoped and 'events' has been shadowed.

Upvotes: 2

Alex Dresko
Alex Dresko

Reputation: 5203

Why not change your code to look like this (which works)?

module display.events {
    export class Event {
    }
}

module display.events {
    export class DisplayEvent extends events.Event {
    }
}

Upvotes: 1

Related Questions