Modules
TypeScript also has the concept of external modules or just modules. The main difference between using modules (instead of namespaces) is that after declaring all our modules, we will not import them using an HTML <script>
tag and we will be able to use a module loader instead.
A module loader is a tool that allows us to have better control over the module loading process. This allows us to perform tasks such as loading files asynchronously or combining multiple modules into a single highly optimized file with ease.
Using the <script>
tag is not recommended because when a web browser finds a <script>
tag, it downloads the file using asynchronous requests. We should attempt to load as many files as possible using asynchronous requests because ...
Get TypeScript: Modern JavaScript Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.