December 2016
Intermediate to advanced
841 pages
17h
English
TypeScript features namespaces (previously known as internal modules). Namespaces are mainly used to organize our code.
If we are working on a large application, as the code base grows we will need to introduce some kind of organization scheme to avoid naming collisions and make our code easier to follow and understand.
We can use namespaces to encapsulate interfaces, classes, and objects that are somehow related. For example, we could wrap all our application models inside an internal module named model:
namespace app {
export class UserModel {
// ...
}
}When we declare a namespace, all its entities are private by default. We can use the export keyword to declare what parts of our namespace we wish to make public.
We are allowed to ...
Read now
Unlock full access