Legacy external modules (design time only)

Before TypeScript 1.5, external modules were declared using a specific design-time syntax. However, once compiled into JavaScript, modules were transformed into AMD, CommonJS, UMD, or SystemJS modules.

We should try to avoid using the legacy external module syntax and use the new ES6 syntax instead. However, we will take a quick look at the external module syntax, because it is still possible to face it sometimes in old applications and documentation.

To export a module using the legacy external module syntax, we need to use the export keyword. We can apply the export keyword directly to a class or interface as follows:

export class User { 
 // ... 
} 

We can also use the export keyword on its own by ...

Get Learning TypeScript 2.x - Second Edition 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.