Home

Awesome

ts-compiler

TypeScript compilation via the typescript-api.

This version is compatable with TypeScript 1.0.

Build Status Dependency Status NPM version Views

NPM

TypeScript Usage

/// <reference path="node_modules/ts-compiler/ts-compiler.d.ts" />
import ts = require('ts-compiler');

ts.compile(
  ['foo.ts', 'bar.ts'],
  { skipWrite: true },
  (err: Error, results: ts.OutputFile[]) => {

    var foo = results[0];
    console.log(foo.text);

    var bar = results[1];
    console.log(bar.text);
  });

JavaScript Usage

var ts = require('ts-compiler');

ts.compile(
  ['foo.ts', 'bar.ts'],
  { skipWrite: true },
  function(err, results) {

    var foo = results[0];
    console.log(foo.text);

    var bar = results[1];
    console.log(bar.text);
});

Module API

ts.compile(files: string[], options?: ICompilerOptions, callback?: Function): BatchCompiler

ts.OutputFile

ts.ICompilerOptions

Though all natively supported TypeScript compiler options will be passed through to the real compiler, it might not always make sense from an API standpoint. Use with common sense.

options.declaration

Generates corresponding .d.ts file.

options.mapRoot

Specifies the location where debugger should locate map files instead of generated locations.

options.module

Specify module code generation: commonjs or amd

options.noImplicitAny

Warn on expressions and declarations with an implied any type.

options.noResolve

Skip resolution and preprocessing.

options.out

Concatenate and emit output to single file.

options.outDir

Redirect output structure to the directory.

options.removeComments

Do not emit comments to output.

options.sourcemap

Generates corresponding .map file.

options.sourceRoot

Specifies the location where debugger should locate TypeScript files instead of source locations.

options.target

Specify ECMAScript target version: 'ES3' or 'ES5'

options.optionsFile

Insert command line options and files from a file. This is natively supported by the tsc command, but as a different @file key.

skipWrite

Skips writing the output files. This flag is unique to ts-compiler.

License

Released under the MIT license.

Bitdeli Badge