Compile TypeScript files to JavaScript.


Compile TypeScipt source code.

Inside your grunt.js file add a section named type. This section specifies the source files to compile and the options passed to TypeScript compiler.

This defines what files this task will compile and should contain key:value pairs.

The key (destination) can be an unique path (supports grunt.template) and the value (source) should be a filepath or an array of filepaths (supports minimatch).

When compiling to a directory you must add a trailing slash to the destination.

This controls how this task operates and should contain key:value pairs, see options below.

This option adjusts the folder structure when compiled to the destination directory. When not explicitly set, best effort is made to locate the basePath by comparing all source filepaths left to right for a common pattern.

This option performs a flat compilation that dumps all the files into the root of the destination directory, overwriting files if they exist.

Forces the compiler to emit comments to output.

Propagate constants to emitted code.

Forces the compiler to minimize whitespaces.

Specify module code generation. Valid values are commonjs (default) or amd.

Allow with statements in TypeScript source code.

Do not include a default lib.d.ts with global declarations.

Do not optimize module codegen.

Skip resolution and preprocessing.

Select style checking options (examples 'requireSemi:off' 'eqeqeq;bitwise:off'). Valid checkig options are: bitwise, blockInCompoundStmt, eqeqeq, forin, emptyBlocks, newMustBeUsed, requireSemi, assignmentInCond, eqnull, evalOK, innerScopeDeclEscape, funcInLoop, reDeclareLocal, literalSubscript and implicitAny. This options are similar to JsHint options.

Specify ECMAScript target version: 'ES3' (default), or 'ES3'.

Path to the tsc TypeScript compiler. By default, grunt-type uses the compiler installed in the system or a bundled version of the compiler ( currently version 0.8.x).

type: {
  compile: {
    files: {
      'path/to/simple.js': ['path/to/type1.ts'],
      'path/to/concat.js': ['path/to/type2.ts',
      'path/to/many/*.js': ['path/to/**/*.ts']
    options: {
      target: 'ES5'
  options: {
    module: 'amd',
    style: 'eqeqeq;bitwise'


Task submitted by Alvaro Vilanova.