Typescript allows you to define modules that are closely related to what will happen in ECMAScript 6. The following example is taken from the specification:
module outer { var local = 1; export var a = local; export module inner { export var x = 10; } }
As you can see, modules have names and can be nested. If you use periods in module names, typescript compiles this for nested modules as follows:
module ABC { export var x = 1; }
It is equal
module A { module B { module C { export var x = 1; } } }
It is also important that if you reuse the same module name in the same typescript program, the code will belong to the same module. Therefore, you can use nested modules to implement hierarchical namespaces.
Valentin Oct 05 '12 at 8:12 2012-10-05 08:12
source share