gulp-tsc

raw JSON →
1.3.2 verified Fri May 01 auth: no javascript deprecated

A gulp plugin that wraps the TypeScript compiler (tsc) to transpile .ts files within gulp workflows. Current stable version is 1.3.2. It supports TypeScript versions from 0.9.1 to 2.1.0, providing a configurable interface for compilation options like module, target, declarations, and source maps. It locates the tsc binary from the local typescript package, shell PATH, or bundled fallback. Compared to alternatives like gulp-typescript, gulp-tsc uses the CLI tsc rather than the compiler API, making it simpler but less flexible for advanced use cases (e.g., no incremental compilation, no project references). The package is lightweight and direct but has limited maintenance and no support for newer TypeScript features.

error TypeError: gulp-tsc is not a function
cause Incorrect import (ESM import syntax with default import) or missing require.
fix
Use const typescript = require('gulp-tsc') instead of import.
error Error: Cannot find module 'typescript'
cause The typescript package is not installed or not in node_modules.
fix
Run npm install typescript --save-dev to add TypeScript as a dev dependency.
error TypeScript compiler version mismatch. The compiler API is incompatible.
cause The installed TypeScript version is newer than 2.1.0, which gulp-tsc does not support.
fix
Downgrade TypeScript to version <=2.1.0 or switch to a modern plugin like gulp-typescript.
deprecated gulp-tsc is no longer actively maintained and only supports TypeScript up to version 2.1. Incompatible with newer TypeScript versions.
fix Switch to a maintained alternative like gulp-typescript or use gulp with tsc directly via gulp-shell or similar.
breaking Option 'allowbool' only works with TypeScript 0.9.1.1 and may be ignored in newer versions.
fix Remove 'allowbool' option; it is not a standard TypeScript compiler flag.
gotcha The 'outDir' option does not affect the actual tsc output directory; it only modifies paths in the stream.
fix Use 'outDir' to set the destination for source maps and declarations, but tsc's --outDir is not directly controlled; specify 'out' or rely on gulp.dest.
gotcha If 'declaration' is true, generated .d.ts files are included in the stream, but the file paths may be incorrect unless 'outDir' is set to the correct output directory.
fix Always set 'outDir' to the same as gulp.dest path when using declarations to ensure correct reference paths.
npm install gulp-tsc
yarn add gulp-tsc
pnpm add gulp-tsc

Illustrates basic usage of gulp-tsc to compile TypeScript files, with options for ES5 target, CommonJS modules, and declaration generation.

const gulp = require('gulp');
const typescript = require('gulp-tsc');

gulp.task('compile', function() {
  return gulp.src('src/**/*.ts')
    .pipe(typescript({
      target: 'ES5',
      module: 'commonjs',
      declaration: true
    }))
    .pipe(gulp.dest('dist'));
});