In several examples in this book, the code was enclosed inside a function body:
(function () {
//code here
})();
This way, all symbols being declared inside a function body are local to that function and are not visible outside of the function body in other TypeScript files. This is a best practice in JavaScript. In fact, global symbols shared between several files, possibly written by different people, may cause unwanted interactions, thereby causing hard-to-find bugs.
Therefore, global symbols must be carefully planned with the whole development team. It is best practice to organize all symbols that must be shared among several files into trees rooted in a few global symbols that are agreed upon by the whole development team. For instance, jQuery is the root symbol of the jQuery library and all public symbols of this library are available as nested properties of...