Support for UMD module definitions

Some libraries are designed to be used in many module loaders, or with no module loading (global variables).These are known as UMD or Isomorphic modules.These libraries can be accessed through either an import or a global variable.

For example:

math-lib.d.ts
  1. export const isPrime(x: number): boolean;
  2. export as namespace mathLib;

The library can then be used as an import within modules:

  1. import { isPrime } from "math-lib";
  2. isPrime(2);
  3. mathLib.isPrime(2); // ERROR: can't use the global definition from inside a module

It can also be used as a global variable, but only inside of a script.(A script is a file with no imports or exports.)

  1. mathLib.isPrime(2);