November 2019
Beginner
804 pages
20h 1m
English
As we have seen, since ES2015 was released, modules have been a part of the specification. Given that TypeScript is a superset of JavaScript, it, of course, supports them as well and uses the same keywords: export and import.
As with ESM, TypeScript modules have their own scope and thus they don't pollute the global scope. Unless you export a symbol, it remains internal to the module and is not visible to the outside world.
You'll certainly appreciate the similarity of this TypeScript example to the previous ESM one:
// my-utils-module.ts const myPrivateKey: string = "Secret"; export const myPublicKey: string = "Public"; export enum MessageType { INFORMATION, WARNING, ERROR, DEBUG } // exported interface export interface ...Read now
Unlock full access