In TypeScript, just as in ECMAScript 2015, any file containing a top-level
exportis considered a module.
Conversely, a file without any top-level import or export declarations is treated as a script whose contents are available in the global scope (and therefore to modules as well).
Modules are executed within their own scope, not in the global scope. This means that variables, functions, classes, etc. declared in a module are not visible outside the module unless they are explicitly exported using one of the export forms. Conversely, to consume a variable, function, class, interface, etc. exported from a different module, it has to be imported using one of the import forms.
Export All as
export = And
import = require
When exporting a module using
export =, TypeScript-specific
import module = require("module") must be used to import the module.