Search code examples
dojotypescriptamd

How to access an interface from a typescript.d.ts file when the module names conflict?


How can I access the i1 from within esri.dijit?

module dijit {
    interface i1 {};
}

module esri {
    module dijit {
        interface i2 {}
        interface i3 extends dijit.i2, dijit.i1 {}
    }
}

See Playground example.


Solution

  • Two things. First you need to export an interface for it to be usable outside the module so:

    module dijit {
        export interface i1 {};
    }
    

    Secondly if you are going to use the same name locally the global name dijit is going to be shadowed. So you need to create an alias :

    module dijit {
        export interface i1 {};
    }
    import alias = dijit;
    

    Now your complete code:

    module dijit {
        export interface i1 {};
    }
    import alias = dijit;
    
    module esri {   
        module dijit {
            export interface i2 {}
            interface i3 extends dijit.i2, alias.i1 {}
        }
    }