0

I have a interface definition

namespace shamethethrones.google { import Marker = google.maps.Marker; export interface MarkerColleciton { [key: string]: Marker; } }

but the issue is google.maps.Marker doesn't exist because it thinks I'm assuming shamethethrones.google.maps.Marker. How do I specify that I want the root namespace google and not shamethethrones.google?

Thanks

1 Answer 1

1

You can try moving import outside of the namespace declaration:

import Marker = google.maps.Marker;

namespace shamethethrones.google {
    export interface MarkerColleciton
    {
        [key: string]: Marker;
    }
}
Sign up to request clarification or add additional context in comments.

18 Comments

That works except then Marker becomes global and if I import somewhere else if will get a duplicate identifier error.
Exactly. The reasoning why its not working otherwise you can see in this post: stackoverflow.com/questions/36249838/… . Namespases are all about structuring global naming. My suggestion - forget about namespaces and use modules.
I've tried looking into modules but it seems the requiring is done at run time. I want my compiled typescript to be combined into one file so the browser only has 1 request to do instead of around 20 files I have now. Have I misunderstood modules?
If you want to have only one file it is possible with modules - check out tools like systemjsbuilder, webpack, browserify. As a side note - loading 20 files separately is not nesessary a bad thing - you might benefit from shorter loading times as most likely you will not import all 20 files at once and their imports will be distributed 'over time' when user will be navigating through your program.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.