index.js
function compileTS (module) {
  var exitCode = 0;
  var tmpDir = path.join(options.tmpDir, "tsreq");
  var relativeFolder = path.dirname(path.relative(process.cwd(), module.filename));
  var jsname = path.join(tmpDir, relativeFolder, path.basename(module.filename, ".ts") + ".js");

  if (!isModified(module.filename, jsname)) {
    return jsname;
  }

  var argv = [
    "node",
    "tsc.js",
    !! options.emitOnError ? "" : "--noEmitOnError",
    "--nolib",
    "--rootDir",
    process.cwd(),
    "--target",
    options.targetES5 ? "ES5" : "ES3", !! options.moduleKind ? "--module" : "", !! options.moduleKind ? options.moduleKind : "",
    "--outDir",
    tmpDir,
    libPath,
    options.nodeLib ? path.resolve(__dirname, "typings/node.d.ts") : null,
    module.filename
  ];

  var proc = merge(merge({}, process), {
    argv: compact(argv),
    exit: function(code) {
      if (code !== 0 && options.exitOnError) {
        console.error('Fatal Error. Unable to compile TypeScript file. Exiting.');
        process.exit(code);
      }
      exitCode = code;
    }
  });

  var sandbox = {
    process: proc,
    require: require,
    module: module,
    Buffer: Buffer,
    setTimeout: setTimeout,
    clearTimeout: clearTimeout,
    __filename: tsc
  };

  tscScript.runInNewContext(sandbox);
  if (exitCode !== 0) {
    throw new Error('Unable to compile TypeScript file.');
  }

  return jsname;
}
function compileTS (module) {
  var exitCode = 0;
  var tmpDir = path.join(options.tmpDir, "tsreq");
  var relativeFolder = path.dirname(path.relative(process.cwd(), module.filename));
  var jsname = path.join(tmpDir, relativeFolder, path.basename(module.filename, ".ts") + ".js");

  if (!isModified(module.filename, jsname)) {
    return jsname;
  }

  var argv = [
    "node",
    "tsc.js",
    !! options.emitOnError ? "" : "--noEmitOnError",
    "--nolib",
    "--rootDir",
    process.cwd(),
    "--target",
    options.targetES5 ? "ES5" : "ES3", !! options.moduleKind ? "--module" : "", !! options.moduleKind ? options.moduleKind : "",
    "--outDir",
    tmpDir,
    libPath,
    options.nodeLib ? path.resolve(__dirname, "typings/node.d.ts") : null,
    module.filename
  ];

  var proc = merge(merge({}, process), {
    argv: compact(argv),
    exit: function(code) {
      if (code !== 0 && options.exitOnError) {
        console.error('Fatal Error. Unable to compile TypeScript file. Exiting.');
        process.exit(code);
      }
      exitCode = code;
    }
  });

  var sandbox = {
    process: proc,
    require: require,
    module: module,
    Buffer: Buffer,
    setTimeout: setTimeout,
    clearTimeout: clearTimeout,
    __filename: tsc
  };

  tscScript.runInNewContext(sandbox);
  if (exitCode !== 0) {
    throw new Error('Unable to compile TypeScript file.');
  }

  return jsname;
}
Compiles TypeScript file, returns js file path
@return {string} js file path