Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

plugin-typescript

frankwallis10.7kMIT8.0.0

TypeScript loader for SystemJS

systemjs, jspm, es6, typescript, ts, tsx, angular2, react, bundle, plugin, loader

readme

plugin-typescript

TypeScript loader for SystemJS

build status Support

Overview

A plugin for SystemJS which enables you to System.import TypeScript files directly. The files are transpiled in the browser and compilation errors written to the console.

Starting with JSPM 0.17.0 (currently in beta) this plugin will be the officially supported mechanism for transpiling TypeScript. It provides the ability to transpile TypeScript and ES2015+ files on the fly when then are loaded by SystemJS.

plugin-typescript supports TypeScript 2.0.0 and higher
For TypeScript 1.8.1 use plugin-typescript 4.0.16
For TypeScript 1.7.5 and below use plugin-typescript 2.x.x

Installation

JSPM

Install plugin-typescript like this:

jspm install ts

All the SystemJS configuration will be created automatically by JSPM.

If you are using SystemJS without JSPM

Add SystemJS map configuration for plugin-typescript and typescript:

SystemJS.config({
  packages: {
    "ts": {
      "main": "lib/plugin.js"
    },
    "typescript": {
      "main": "lib/typescript.js",
      "meta": {
        "lib/typescript.js": {
          "exports": "ts"
        }
      }
    }
  },
  map: {
    "ts": "path/to/plugin-typescript",
    "typescript": "path/to/typescript"
  },
  transpiler: 'ts'
});

Setup

Make plugin-typescript the default transpiler for js and ts files

System.config({
  transpiler: "ts"
  packages: {
    "app": {
      "defaultExtension": "ts",
    }
  }
});

This will tell SystemJS to transpile all modules (.js and .ts) using plugin-typescript. It is also possible to configure plugin-typescript to load specific files, using packages configuration

System.config({
  transpiler: "babel",
  packages: {
    "src": {
      "defaultExtension": "ts",
      "meta": {
        "*.ts": {
          "loader": "ts"
        }
      }
    }
  }
});

This will cause all .ts files in the "src" package to be loaded through plugin-typescript.

See the example projects contained within this repository for a working setup.

Configuration

Configuration settings can be passed to the compiler via "typescriptOptions":

System.config({
  typescriptOptions: {
    module: "system",
    noImplicitAny: true,
    tsconfig: true                  // also accepts a path
  }
});

It is also possible to override the default configuration for specific files, using meta configuration:

System.config({
  transpiler: "typescript",
  packages: {
    "src": {
      "defaultExtension": "ts",
      "meta": {
         "*.ts": {
            "typescriptOptions": {
               "noImplicitAny": true
            }
         }
      }
    }
  }
});

All the usual TypeScript compiler options are supported, as well as these additional ones:

tsconfig

A boolean flag which instructs the plugin to load configuration from "tsconfig.json". To override the location of the file set this option to the path of the configuration file, which will be resolved using normal SystemJS resolution.

The file location will be resolved using normal SystemJS resolution, and compiler options which do not conflict with those required by plugin-typescript will be loaded from the compilerOptions section of the file.

Features

Hot-Reload support

The example projects show how to use plugin-typescript in conjuntion with systemjs-hot-reloader

Rollup support

Rollup is supported when transpiling with module: "es6". It can help to reduce the size of your bundles by stripping out unused modules. For more information see here

When compiling in the browser, transpiler errors contain a link to the exact location of the error in the source. This is particularly helpful if you are using Chrome DevTools as your IDE.

Override TypeScript version

To override the version of TypeScript used by the plugin, add an override to the jspm section of your package.json

    "devDependencies": {
        "css": "systemjs/plugin-css@0.1.10",
        "ts": "frankwallis/plugin-typescript@^7.0.5"
    },
    "overrides": {
        "github:frankwallis/plugin-typescript@5.0.1": {
             "dependencies": {
                "typescript": "npm:typescript@2.3.0-dev.20170228"
              }
        }
    }

Examples

To run the example projects:

> git clone https://github.com/frankwallis/plugin-typescript.git
> cd plugin-typescript
> npm install
> cd examples/react          // or examples/angular2 or examples/angular
> jspm install
> npm start

To bundle each example project:

> npm run build             // or jspm build src build/build.js

changelog

5.1.1 (2016-09-04)

Features

  • typings: automatically resolve typings files under 'typings' packages (b01b26a)
  • typings: add 'typings' compiler option (ee8551d)

5.0.20 (2016-09-03)

Bug Fixes

  • scoped-packages: fix for typings resolution under scoped package, bump 5.0.20 (956a5ad)
  • types: patch for jspm@0.16 defaultJsExtensions, bump 5.0.19 (cea087f)

5.0.18 (2016-08-23)

Bug Fixes

  • logging: remove debug logging (e09945c)

5.0.17 (2016-08-22)

Features

  • @types: use existing 'types' compiler option (caf89c1)
  • attypes: fix for resolving type references (987e7f2)
  • @types: support type reference directives (4527d8e)
  • @types: default @types main to index.d.ts (1c7674d)
  • @types: new 'types' compiler option for @types support, bump 5.0.12 (953bcf7)

5.0.11 (2016-08-21)

Bug Fixes

  • reporting: suppress duplicate module resolution errors (af18c80)

Features

  • lib-option: provide back-support for targetLib, don't load lib files when transpiring (3b9dc3b)
  • typescript-2.0: add support for lib compiler option (b2367de)

5.0.9 (2016-08-03)

Features

  • perf: prevent unnecessary calls to getAllDiagnostics (b14ed99)
  • rollup: fix failing tests (542da97)
  • rollup: fix failing tests (6f6dd92)
  • rollup: fix failing tests (928eb88)

5.0.8 (2016-07-17)

Features

  • rollup: don't automatically switch output from system -> es6 modules (50198a2)
  • rollup: default allowSyntheticDefaultImports to true (3774d4e)

5.0.6 (2016-07-16)

Features

  • logging: specify type of log message (f10d977)
  • rollup: fix for bundling issue when outputting commonjs (c83e7ab)

5.0.4 (2016-07-16)

Features

  • strict-mode: improve typeCheck 'strict' (217d67b)
  • rollup: support rollup when bundling (f4bbce2)
  • strict-mode: improve typeCheck 'strict' (dd81c4a)

Bug Fixes

  • augmentation: warn when trying to resolve module 'global', patch for #144 (0890792)

5.0.1 (2016-07-12)

Features

  • wildcard-modules: remove deprecated supportHtmlImports/resolveAmbientRefs from examples and docs (8cb83f6)
  • esm-deps: es modules now support metadata.deps, remove workaround (0a88fda)
  • typescript-2.0.0: upgrade to typescript@2.0.0, bump 5.0.0 (1aa05b3)

4.0.16 (2016-05-16)

Bug Fixes

  • plugin-json: fix for issue importing json with plugin-json, bump 4.0.16 (d47f836)

4.0.15 (2016-05-15)

Bug Fixes

  • html-imports: fix for html imports using commonjs/es6, bump 4.0.15 (ea6bd13)
  • logging: turn off debug logging, bump 4.0.14 (8beb22f)
  • elided-imports: add fix for plugin, bump 4.0.12 (da5a93e)
  • elided-imports: add fix for es6 output, bump 4.0.11 (bc9bfb0)
  • elided-imports: add fix to set metadata.deps after instantiation (647828a)

Features

  • e2e: add some integration tests (ba1ca96)
  • elided-imports: add tests for builder (c5b26ee)
  • elided-imports: add tests for execution (d75baaa)

4.0.10 (2016-05-09)

Bug Fixes

  • ambientExternalModules: fix for issue compiling declare module '../somemodule', closes #125, bump 4.0.10 (ea8a49c)

4.0.9 (2016-05-04)

Bug Fixes

  • relative-typings: lookup typings for all js imports, add test, bump 4.0.9 (a15da0d)

4.0.8 (2016-04-30)

Bug Fixes

  • build-execution: use metadata.deps to inject files into build or add import source when outputting es6 (08631fc)

4.0.7 (2016-04-22)

Bug Fixes

  • double-evaluation: fix for modules being evaluated twice, closes #119, bump 4.0.7 (3ae63b7)

4.0.6 (2016-04-17)

Bug Fixes

  • elided-imports: fix for issue where .ts import file was being elided, closes #117, bump 4.0.6 (58cc11c)

4.0.5 (2016-03-27)

Bug Fixes

  • strict: fix for typeCheck: 'strict' (7560f57)

4.0.4 (2016-03-27)

Bug Fixes

  • hot-reload: add relativeTo setting for chokidar (6c6fd1c)
  • html-import: fix for importing html with module: 'es6' (7455a00)

4.0.2 (2016-03-02)

Bug Fixes

  • angular2: fix the clear button (72bd341)
  • errors: improve error reporting when files are missing (5d03379)

Features

  • angular2: improve angular2 example (e1047f6)

4.0.1 (2016-02-22)

Features

  • typings: enable typings to be specified with filename of bundle (0d99c42)
  • typings: get typings configuration from meta (b055f46)

3.0.3 (2016-02-14)

Features

  • typingsMap: add typingsMap option (e843a48)
  • typingsMap: enable type-checking in angular2 example (4334271)

3.0.2 (2016-02-08)

Bug Fixes

  • bundling: revert rollup support change (57c0250)

3.0.1 (2016-02-06)

Bug Fixes

  • transpile: override noEmit option in tsconfig (921a829)

Features

  • rollup: output es6 when bundling (c81dd2d)

2.6.0 (2016-02-04)

Bug Fixes

  • sourceMap: set metadata.sourceMap as object not string (9563d72)

2.5.11 (2016-02-04)

Features

  • targetLib: add the targetLib option to use lib.d.ts (22cf0d8)

2.5.10 (2016-02-03)

Bug Fixes

  • bundling: switch to using System.import instead of metadata.deps (671ad1e)
  • transpile: add new 'suppressOutputPathCheck' option when transpiling (d2158e0)

2.5.8 (2016-01-31)

Bug Fixes

  • source-maps: undo previous change to fix source maps (9a8937f)
  • js-transpile: redirect transpiler output to prevent 'cannot overwrite existing file' error in typescript-1.8.0-beta (6a02fe5)
  • windows: fix tests on windows (9183e0d)

2.5.3 (2016-01-26)

Bug Fixes

  • example: add workaround for module detection issue (8743a79)
  • references: fix to suppress type errors from reference files without references (2dc7b8a)

Features

  • hot-reload: add support for hot-reloading css in examples (8ecbf6b)
  • jspm-0.17: fix the bundle, rename bundle -> build (28b8ccf)
  • jspm-0.17: update angular2 project (zonejs issue in browser) (bffdf6e)
  • jspm-0.17: update readme (0ded2dc)
  • jspm-0.17: upgrade react and angular packages (679a06e)
  • jspm-0.17: use plugin-typescript as default transpiler (edd5b6c)
  • npm: exclude files from npm (5fb8a43)

2.5.1 (2016-01-23)

Bug Fixes

  • example: fix react example (17e4dc0)
  • hot-reload: re-check files when dependents change (33e7505)

2.5.0 (2016-01-23)

Features

  • hot-reload: support hot-reloading (95fd23e)
  • warnings: add a warning if output format is not system.register (8282b3c)

2.4.9 (2016-01-20)

Bug Fixes

  • bundling: fix for babel bundling (2ae35c3)

2.4.8 (2016-01-20)

Bug Fixes

  • bundling: workaround for resolution errors when bundling, switch to system.register format (467cada)

2.4.7 (2016-01-16)

Bug Fixes

  • source-maps: fix for source-maps not working (d628f2a)
  • tests: fix paths issue when running tests on windows (396adbc)

2.4.6 (2016-01-09)

Bug Fixes

  • translate: translate should return load.source instead of load, closes #81 (ff32996)
  • typings: fix for non-relative typings path, closes #80 (dca6aca)

2.4.5 (2016-01-02)

Bug Fixes

  • moduleResolution: force module resolution into classic mode, bump 2.4.5 (c3b71bf)

2.4.4 (2015-12-23)

Bug Fixes

  • noEmitOnErrors: fix for transpiler not reporting/overriding options which are invalid with isolatedModules, closes #75, bump 2.4.4 (c95c40f)

2.4.3 (2015-12-12)

Bug Fixes

  • source-maps: fix for source-maps not work due to previous change (f3f4d21)

2.4.2 (2015-12-10)

Bug Fixes

  • parse-error: fix for parse error when source map undefined (2eb92c0)

2.4.1 (2015-12-10)

Bug Fixes

  • IE10-Map: remove references to map, bump 2.4.1, closes #70 (59df643)

2.4.0 (2015-12-05)

Bug Fixes

  • module: support output of js in module formats other than 'system' (e.g. 'es6' piped to babel), bump 2.4.0 (f2a6554)

2.3.2 (2015-12-01)

Bug Fixes

  • __moduleName: don't emit __moduleName in build mode (1cee03a)
  • strict-mode: fail the build when typeCheck errors in strict mode (14141ab)

2.3.0 (2015-12-01)

2.2.3 (2015-11-29)

Bug Fixes

  • Object.assign: remove usage of Object.assign, closes #61 (7ee0da7)

2.2.2 (2015-11-15)

Features

  • typings: support loading typings from package.son (resolveTypings: true) (519baa1)

2.2.0 (2015-11-04)

Bug Fixes

  • extensions: sanitize extensions (b3c1fc5)
  • resolution: fix for json file resolution (f642d49)

Features

  • no-lib: observe no-lib option (591dca4)
  • no-lib-check: use the built in skipDefaultLibCheck compiler option (1d2d09d)

2.1.6 (2015-11-03)

Bug Fixes

  • module: fix for __moduleName reference error (7d8b545)
  • source-maps: fix for source maps (dcd2a3f)
  • tsconfig: fix for error when declaration files present but typeCheck false, bump 2.1.6 (c92c0c1)

Features

  • 0.17: convert source to typescript and precompile (2310fbd)
  • 0.17: target es5 but use lib.es6.d.ts, strip comments (800f702)
  • examples: use jspm.Builder instead of systemjs-builder (d1e064d)

2.1.5 (2015-11-01)

Bug Fixes

  • example: fix angular2 config (b3a56dd)
  • logger: fix for typo in logger, bump 2.1.5 (de4e46b)

2.1.4 (2015-10-26)

Features

  • linked-errors: link errors to location in source file, bump 2.1.4 (aeabfa9)

2.1.3 (2015-10-26)

Bug Fixes

  • strict: fix bug in strict mode, bump 2.1.3 (e36836c)

2.1.2 (2015-10-21)

Bug Fixes

2.1.0 (2015-10-14)

Features

  • strict: add a strict mode which fails the build on type-check errors (673f416)
  • tsconfig: load compiler options from tsconfig.json (70c10bf)
  • tsconfig: load declaration files from tsconfig.json (2760c34)
  • tsconfig: use tsconfig in examples (5ad7e45)

2.0.17 (2015-09-19)

Bug Fixes

  • bundling: fix for type-checking error when bundling with systemjs-builder@0.14, bump 2.0.17 (c33811e)
  • transpiler: fix for incorrect return type from resolveModuleNames, bump 2.0.16 (07e7162)
  • type-checker: put back unneeded code, bump 2.0.15 (e2da77d)
  • incremental-build: fix the flow task (916c38b)

2.0.11 (2015-09-01)

Features

  • host-resolution: sanitisation of tsx.ts -> tsx is no longer needed (9c6c01f)
  • multiple-packages: support type-checking over multiple packages (a702177)

2.0.10 (2015-08-31)

Features

  • angular2: try out ng-model (6cc6802)
  • external-modules: import example-service from external package (490a1f9)
  • html-templates: add support for importing .html files as strings without type-check errors, bump 2.0.10 (0d138e2)

2.0.9 (2015-08-27)

Features

  • react: add support for tsx files (773f75a)
  • react: allow import a from "file.tsx", bump 2.0.9 (1e46a2b)

2.0.8 (2015-08-27)

Bug Fixes

  • example: fix the example project bundling (fa80ac1)

Features

  • react: add angular1 example back again (fda0002)
  • react: add react example (eec3ce4)
  • react: move angular2 example to subfolder (408975d)
  • react: support the jsx configuration option, bump 2.0.8 (e51793d)

2.0.7 (2015-08-24)

Bug Fixes

  • source-maps: fix source-maps, bump 2.0.6 (a74c768)
  • es3: add support for target="es3" (d899a97)
  • example: add correct jspm version to devDependencies (df46c9a)
  • typescriptOptions: fix for undefined error when typescriptOptions not specified (d0f24bb)
  • bundling: fix for bundling error (f4d945e)

2.0.0 (2015-07-02)

Bug Fixes

  • performance: don't type-check the default lib for better performance (1c093c8)
  • deps: fix to use anonymous modules (475a4ea)
  • reference-errors: trap compiler errors in reference files (b5b8066)
  • module-name: set __moduleName variable (848c475)

Features

  • transpile: working transpile (df0354c)
  • transpiler: error on syntax error (a75c497)
  • type-check: implement type-checking (ec0fa6d)

1.0.5 (2015-06-08)

Features

  • es6: enable setting of target output via options (2ee7380)
  • inject: add index-inject.html (71a2216)
  • resolveAmbientRefs: add option "resolveAmbientRefs" to disable systems resolution of ambient reference files, default is true (7c9f531)

1.0.4 (2015-05-19)

Bug Fixes

  • inject: enable using bundles created with jspm bundle --inject, fixes #19 (dfc8e5d)
  • import-css: bundling issue when css import present, fixes #19 (ecc42a3)
  • import-js: fix to enable importing javascript files and for strange compiler bug (93387eb)

1.0.0 (2015-04-20)

Features

  • es6: update the example project to use Map (3e11374)
  • es6: use lib.es6.d.ts to enable Symbol (76f0928)

0.6.7 (2015-04-09)

Bug Fixes

  • export-import: export import no longer available (e20930c)
  • ts-15: add tests for export import (3f8174e)
  • ts-15: rename Filename -> FileName (38f11c4)

0.6.4 (2015-04-02)

Bug Fixes

  • deps: pin typescript at 1.4.1 (84fe362)
  • bundling: fix the bundling example (d1e95b4)

Features

  • jspm-0.15: update to jspm 0.15 (92efd81)
  • options: add support for "typescriptOptions" (a7a53f2)

0.6.2 (2015-03-26)

Bug Fixes

  • ambient-refs: ensure that the ambient references are resolved to the same file (693fa53)
  • bundling: change the registry from nom -> jspm (3aae941)
  • bundling: update to systemjs-builder 0.10.0 and fix the bundle task (7467a61)
  • lib.d.ts: improve performance by tagging lib.d.ts correctly (e382d99)

0.6.1 (2015-03-24)

Bug Fixes

  • lib.d.ts: put in workaround for __moduleName not set correctly with traceur 0.0.84 (32a3d60)
  • lib.d.ts: yet another fix for lib.d.ts resolution (af9d9d9)
  • reference-errors: fix for issue where errors in reference files were not picked up (950b2dc)
  • references: add tests for ambient references (c162d8a)
  • references: add tests for circular references and reference file type errors (22cbf3b)

Features

  • ambient-references: add proper support for ambient references (8af5cca)

0.5.10 (2015-02-22)

Bug Fixes

  • dependencies: add the jspm dependencies back in and bump 0.5.9 (3cbf1e6)
  • example: swap http-server for live-server (high cpu) (b6bbf3f)
  • nested-types: add fix for nested type errors issue (fa152c1)
  • nested-types: bump 0.5.10 (02fe3e9)
  • dependencies: fix the development dependencies & tests (809352e)

Features

  • example: open the example project automatcally (2b108c7)
  • travis-ci: add the travis configuration (a79978f)

0.5.7 (2015-02-06)

Features

  • default-lib: resolve the default lib properly (789f616)
  • es6: restructure and es6ify (ecb6a6f)
  • integration: configure the example project (ef08576)
  • language-service: working build with language service (13ab811)
  • language-services: Compile with language services (14809bf)
  • plugin: get the example project/plugin working (6213f36)
  • publish: reduce logging (ba47c5a)
  • source-maps: get the source maps working (4705ac8)