MCPcopy Index your code
hub / github.com/frankwallis/plugin-typescript

github.com/frankwallis/plugin-typescript @9.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 9.0.0 ↗ · + Follow
222 symbols 456 edges 145 files 0 documented · 0% 201 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
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

Link to source from transpiler errors

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

Extension points exported contracts — how you extend this code

IAmbient (Interface)
(no doc) [6 implementers]
test/fixtures-es6/ambients/resolved/ambient/ambient.d.ts
IExampleService (Interface)
(no doc) [3 implementers]
examples/angular/src/example-types.ts
Builder (Interface)
(no doc)
test/builder-spec.ts
SourceFile (Interface)
(no doc)
src/compiler-host.ts
Module (Interface)
(no doc)
src/types.d.ts
Sun (Interface)
(no doc) [1 implementers]
test/fixtures-es6/circular/circular1.d.ts
PluginOptions (Interface)
(no doc)
src/types.d.ts
INgStatic (Interface)
(no doc)
test/fixtures-es6/external.d.ts

Core symbols most depended-on inside this repo

config
called by 43
test/builder-spec.ts
log
called by 27
src/logger.ts
defaultConfig
called by 19
test/builder-spec.ts
parseOptions
called by 19
src/resolve-options.ts
defaultConfig
called by 15
test/plugin-spec.ts
doTranspile
called by 14
test/transpiler-spec.ts
resolveOptions
called by 14
src/resolve-options.ts
bundle
called by 12
test/builder-spec.ts

Shape

Function 79
Method 72
Class 48
Interface 20
Enum 3

Languages

TypeScript100%

Modules by API surface

lib/plugin.js31 symbols
src/utils.ts17 symbols
src/compiler-host.ts17 symbols
examples/react/src/calculator.tsx8 symbols
examples/angular2/src/calculator-component.ts8 symbols
test/builder-spec.ts7 symbols
src/logger.ts7 symbols
test/fixtures-es6/ambients/ambient-reference-disabled.ts6 symbols
src/resolve-options.ts6 symbols
examples/react/src/calculator-store.tsx6 symbols
examples/angular2/src/calculator-store.ts6 symbols
test/fixtures-es6/program1/type-error.ts4 symbols

For agents

$ claude mcp add plugin-typescript \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact