Search code examples
angularjstypescriptcommonjssystemjs

How to make it possible to use Typescript with SystemJS and Angular?


I'm trying to make SystemJS work with Typescript, but they seem to conflict with each other.

How can I take advantage of the autoloading from System.js without it conflicting with keywords on Typescript? using import / require makes Typescript using it's own way for loading and referencing files, although it translates export as module.exports = ..., it doesn't do the same for import

Is it possible at all to achieve this or I'll have to wait for Typescript to support ES6 keywords?


Solution

  • TypeScript 1.5 adds support for compiling to ES5 SystemJS module syntax.

    Author a class like:

    export class Foo {}
    

    Then compile with

    tsc --module system foo.ts
    

    The result will be an ES5 module using the SystemJS format.