access “root” module same name as actual submodule

Topics: General
Dec 18, 2013 at 10:22 AM
Edited Dec 18, 2013 at 11:57 AM
I have two modules in TypeScript: http://goo.gl/BdOJ1D
module superModule {
  export interface myInterface { /*...*/ }
}

module app.superModule {
  var x: superModule.myInterface;
}
Notice, that there are two different "superModule" modules. One in root, second as submodule of app module.

The code above is evaluated as there is missing "myInterface" interface, becouse compiler is searching only in app.superModule.

How to access "root" superModule from submodule superModule?
Coordinator
Dec 18, 2013 at 5:17 PM
Similar to how you would work around other name collisions, eg capturing the right 'this', you need to alias the outer super module to another name that doesn't collide. Something like this:
module superModule {
    export interface myInterface { /*...*/ }
}

import mySuperModule = superModule;

module app.superModule {
    var x: mySuperModule.myInterface;
}
Marked as answer by the_ufon on 12/18/2013 at 10:27 AM