Explain "export =" and "export as namespace" syntax in TypeScript

Viewed 17397

I am trying to make use of the type declarations files in the DefinitelyTyped repository. Many of these files use the following pattern:

export = React;
export as namespace React;

Googling around, I've found references to this being used to make a declaration file usable in both module-based and non-module-based systems. However, I'm struggling to find a clear explanation of:

  1. what each of these lines exactly does individually and
  2. how exactly this combination works to support both types of consumers.
1 Answers
Related