typescript-compiler

WebJar for typescript-compiler

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

typescript-compiler
Last Version

Last Version

1.4.1-2
Release Date

Release Date

Type

Type

jar
Description

Description

typescript-compiler
WebJar for typescript-compiler
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/theblacksmith/typescript-compiler

Download typescript-compiler

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/typescript-compiler/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>typescript-compiler</artifactId>
    <version>1.4.1-2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/typescript-compiler/
implementation 'org.webjars.npm:typescript-compiler:1.4.1-2'
// https://jarcasting.com/artifacts/org.webjars.npm/typescript-compiler/
implementation ("org.webjars.npm:typescript-compiler:1.4.1-2")
'org.webjars.npm:typescript-compiler:jar:1.4.1-2'
<dependency org="org.webjars.npm" name="typescript-compiler" rev="1.4.1-2">
  <artifact name="typescript-compiler" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='typescript-compiler', version='1.4.1-2')
)
libraryDependencies += "org.webjars.npm" % "typescript-compiler" % "1.4.1-2"
[org.webjars.npm/typescript-compiler "1.4.1-2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

typescript-compiler

Typescript compiler wrapper. Exposes the TypeScript command line compiler to your code.

Build Status Flattr this git repo

Installing

$ npm install typescript-compiler

Usage

Require the compiler...

var tsc = require('typescript-compiler');

call it like this...

tsc.compile(['a.ts', 'b.ts'], ['--out', 'out.js'])

or this..

var js = tsc.compileString('class TSC { awesome: boolean = true; }')

or even this!

var result = tsc.compileStrings({
				'ship.ts' : 'module Navy { export class Ship { isSunk: boolean; } }',
				'fleet.ts': '///<reference path="ship.ts" />\n' +
							'module Navy { \n' +
							'export class Fleet { ships: Ship[] } '+
							'}'
			})

Did you notice you can use ///<reference /> tags?

Module Interface

Note: A ? indicates an optional parameter

Common Parameters

All Methods accept the following parameters:

tscArgs? : string[]|string,
        The same arguments you can pass to tsc when you run it from the command line
options? : CompilerOptions,
        Options to be passed to the compiler
onError? : fn ( Diagnostic )
        A function you want called for each error the compiler encounters.

Compilation Methods

compile(files, tscArgs?, options?, onError?)

input : string|string[]
        The name of the file or an array of file names to compile.
returns CompilationResult

        Compiles one or many files

        Example
    tsc.compile(['test/cases/ship.ts', 'test/cases/fleet.ts'],
    				'-m commonjs -t ES5 --out test/tmp/navy.js');

compileString(input, tscArgs?, options?, onError?)

input : Map<string>|StringSource[]|string[]
        The source to compile or an array of sources. The source(s) can be passed as strings or StringSource objects.
returns string

        Compiles a string

        Example
tsc.compileString('module Navy { class Ship { isSunk: boolean; } }')

compileStrings(input, tscArgs?, options?, onError?)

input : Map<string>|StringSource|string[]
    A collection of sources to be compiled.
returns CompilationResult

        Compiles one or many strings

        Example
tsc.compileStrings({
    "ship.ts"  : 'module Navy { export class Ship { isSunk: boolean; }}',
    "fleet.ts": '///<reference path="ship.ts" />\n' +
                'module Navy { export class Fleet { ships: Ship[] }}'
   },
   // tscArgs
   '--module commonjs -t ES5 --out navy.js',
   // options (DEPRECATED, will be removed in the next version)
   null,
   // onError
   function(e) { console.log(e) }
)

TSC arguments

When in doubt about what you can pass in the tscArgs param you can run the compiler from the command line to get some help. Every option you see below is accepted as a value for the tscArgs array.

$ tsc
Version 1.1.0.1
Syntax:   tsc [options] [file ...]

Examples: tsc hello.ts
          tsc --out foo.js foo.ts
          tsc @args.txt

Options:
 -d, --declaration  Generates corresponding '.d.ts' file.
 -h, --help         Print this message.
 --mapRoot          Specifies the location where debugger should locate map files instead of generated locations.
 -m, --module       Specify module code generation: 'commonjs' or 'amd'
 --noImplicitAny    Warn on expressions and declarations with an implied 'any' type.
 --out              Concatenate and emit output to single file.
 --outDir           Redirect output structure to the directory.
 --removeComments   Do not emit comments to output.
 --sourceMap        Generates corresponding '.map' file.
 --sourceRoot       Specifies the location where debugger should locate TypeScript files instead of source locations.
 -t, --target       Specify ECMAScript target version: 'ES3' (default), or 'ES5'
 -v, --version      Print the compiler's version.
 -w, --watch        Watch input files.
 @<file>            Insert command line options and files from a file.
org.webjars.npm

The Blacksmith (a.k.a Saulo Vallory)

Versions

Version
1.4.1-2