Andrei Tarutin
Andrei Tarutin

Reputation: 683

Inner module with the same name as outer one

I have definitions for some javascript library. Let's say that it functions can be accessed via module name Lib.

At the same time I've created my module like this:

module Outer.Lib.Inner {
  // some code
}

How can i access outer module Lib inside my own module Outer.Lib.Inner? I've tried it that way:

module Outer.Lib.Inner {
  function SomeFunction(): void {
    // here i am trying to access outer Lib module but compiler thinks i am accessing my Outer.Lib module
    Lib. ....
  
  }
}

Thanks in advance.

Upvotes: 1

Views: 330

Answers (1)

basarat
basarat

Reputation: 276219

how can I qualify the name of the outer module in this situation?

Since the fully qualified name of the outer module Lib conflicts with the inner module declaration we are in Outer.Lib you need to create an alias:

var ExternalLib = Lib; 
// or if you have it in TypeScript: 
// import ExternalLib = Lib;


module Outer.Lib.Inner {
  function SomeFunction(): void {
    // here i am trying to access outer Lib module but compiler thinks i am accessing my Outer.Lib module
    ExternalLib. ....

  }
}

Upvotes: 4

Related Questions