This chapter explains how to use namespaces and modules to avoid name collisions in large code bases. TypeScript namespaces are completely analogous to C# namespaces, while modules are an advanced feature introduced by ES6 specifications to overcome namespaces' pitfalls. Modules are a fundamental building block of Angular applications, which is the topic of the last part of this book. Moreover, notwithstanding ES6 modules are not fully supported by all browsers a they may be processed by JavaScript bundlers such as WebPack (described in Chapter 7, Bundling with WebPack), that assemble JavaScript modules in a way similar to object code-linkers to yield optimized JavaScript code chunks to add to the various web pages.
The following topics will be covered in this chapter:
- Defining namespaces and references to other namespaces
- Defining and using ES6...