As in the title: does TypeScript support namespaces? If so, how do I use them?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Typescript allows to define modules closely related to what will be in ECMAScript 6. The following example is taken from the spec:
As you can see, modules have names and can be nested. If you use dots in module names, typescript will compile this to nested modules as follows:
This is equal to
What’s also important is that if you reuse the exact same module name in one typescript program, the code will belong to the same module. Hence, you can use nested modules to implement hierarchichal namespaces.