AMD modules (runtime only)

If we compile the external module that we defined in the ES6 modules section into an AMD module (using the flag --compile amd), we will generate the following AMD module:

define(["require", "exports"], function (require, exports) { 
    var UserModel = (function () { 
        function UserModel() { 
        } 
        return UserModel; 
    })(); 
    return UserModel; 
}); 

The define function takes an array as its first argument. This array contains a list of the names of the module dependencies. The second argument is a callback that will be invoked once all the module dependencies have been loaded. The callback takes each of the module dependencies as its parameters and contains all the logic from our TypeScript component. Notice how the return type ...

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.