Registry / devops / gulp-typescript

gulp-typescript

JSON →
library6.0.0-alpha.1jsnpmunverified

gulp-typescript is a Gulp plugin designed for integrating TypeScript compilation into Gulp build workflows, offering features like incremental compilation and project reference support. The package is currently in an active development phase, with v5.0.1 being the latest stable release and v6.0.0-alpha.1 actively being developed. New releases, including alphas and minor fixes, are frequent. It serves as a key tool for developers who leverage Gulp for task automation and need to compile TypeScript, providing a direct interface to TypeScript's compiler options and supporting `tsconfig.json` configurations. Its main differentiators include tight integration with Gulp's streaming API, efficient incremental compilation, and support for advanced TypeScript features like custom transformers introduced in v5.

npm install gulp-typescript
INSTALL
IMPORT
SIG · GULP-TYPESCRIPT
G
gulp-typescript
devopsjavascriptv6.0.0-alpha.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ts
const ts = require('gulp-typescript');
import ts from 'gulp-typescript';
Gulpfiles are typically CommonJS modules. While technically possible to use ESM in Gulp with configuration, `require` is the standard and explicitly documented way to import `gulp-typescript`.
createProject
const tsProject = ts.createProject('tsconfig.json');
const tsProject = require('gulp-typescript').createProject('tsconfig.json');
The `createProject` function is a static method on the main `ts` export. It's used for incremental builds and reading `tsconfig.json`.
reporter
ts.reporter.full()
Reporters are accessed as properties of the main `ts` object, e.g., `ts.reporter.full()` or `ts.reporter.defaultReporter()` for logging compilation output. These are typically used in the `.pipe()` chain or as part of error handling.

Demonstrates how to compile TypeScript files using `gulp-typescript` with sourcemaps and `tsconfig.json` support, outputting both JavaScript and declaration files. It also includes a basic watch task for development.

import gulp from 'gulp'; import ts from 'gulp-typescript'; import sourcemaps from 'gulp-sourcemaps'; // Create a TypeScript project instance, optionally reading a tsconfig.json const tsProject = ts.createProject('tsconfig.json', { // Override options from tsconfig.json or define new ones // For example, force ES2017 target if tsconfig is older target: 'ES2017', declaration: true // Generate .d.ts files }); function compileTypeScript() { return gulp.src('src/**/*.ts') // Source TypeScript files .pipe(sourcemaps.init()) // Initialize sourcemaps .pipe(tsProject()) // Compile TypeScript .js // Get JavaScript stream .pipe(sourcemaps.write('.')) // Write sourcemaps to same directory .pipe(gulp.dest('dist')) // Output JavaScript files .dts // Get Declaration stream .pipe(gulp.dest('dist')); // Output Declaration files } // Define a watch task for continuous compilation during development function watchTypeScript() { gulp.watch('src/**/*.ts', compileTypeScript); } export const build = gulp.series(compileTypeScript); export const watch = gulp.series(compileTypeScript, watchTypeScript); export default build;
Debug
Known issues
breakingStarting with v4.0.0 and further solidified in v5.0.0, `gulp-typescript` requires Gulp 4. Older versions of Gulp are not supported. Additionally, `gulp-util` dependency was removed in v4.0.0.
fix
Ensure your project's `gulp` dependency is `^4.0.0` or higher. Upgrade your `gulpfile.js` syntax to Gulp 4 API if necessary.
affects: >=4.0.0
breakingIn v5.0.0, the behavior of compiler errors changed. Outside of watch mode, the Gulp process will now exit when a TypeScript compiler error occurs, aligning with Gulp's new error handling. In watch mode, the process continues.
fix
Handle errors appropriately within your Gulp task, for example, by using `gulp-plumber` to prevent the stream from stopping on errors in watch mode, or by ensuring your TypeScript code is error-free for non-watch builds.
affects: >=5.0.0
gotcha`gulp-typescript` does not handle sourcemap options directly. Options like `sourceMap`, `inlineSourceMap`, `inlineSources` are unsupported. Instead, `gulp-sourcemaps` should be used.
fix
Pipe your TypeScript stream through `gulp-sourcemaps.init()` before `tsProject()` and `gulp-sourcemaps.write()` after the `.js` stream. Example provided in the quickstart.
affects: >=3.0.0
gotchaThe `watch` compiler option is not supported by `gulp-typescript`. Incremental compilation is managed internally by `ts.createProject()`, and file watching should be handled by `gulp.watch()`.
fix
Remove the `watch` option from your `tsconfig.json` or `ts.createProject` options. Implement file watching using `gulp.watch` to trigger compilation tasks.
affects: >=3.0.0
breakingv6.0.0-alpha.1 is a pre-release version. It may introduce further breaking changes not yet fully documented or stable. Use with caution in production environments.
fix
For production, prefer the latest stable v5.x release. If using v6 alpha, closely monitor release notes for breaking changes and update dependencies as advised.
affects: >=6.0.0-alpha.1
breakingWhen compiling with the `declaration: true` option, `gulp-typescript` outputs two streams: one for JavaScript (`.js`) and one for declaration files (`.dts`). Both must be piped to `gulp.dest()` separately.
fix
After piping through `tsProject()`, append `.js.pipe(gulp.dest('output'))` for JavaScript and `.dts.pipe(gulp.dest('output'))` for declaration files to ensure both are written to disk.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: project.src is not a function
Attempting to use `ts.createProject()` without invoking it as a function or incorrectly accessing its properties.
fix
Ensure `ts.createProject()` is called to create the project instance, e.g., `const tsProject = ts.createProject('tsconfig.json');`, and then use `tsProject()` as the gulp plugin, e.g., `gulp.src('src/**/*.ts').pipe(tsProject()).js.pipe(...)`.
Error: Not a vinyl file. Make sure that you're not using .js or .d.ts files in your gulp.src statement when using `allowJs` or `declaration`
`gulp-typescript` typically expects `.ts` or `.tsx` files as input unless `allowJs` is enabled. This error can occur if you pass already compiled JS/DTS files to the TypeScript stream without proper configuration.
fix
Verify that your `gulp.src()` glob pattern only selects TypeScript source files (`.ts`, `.tsx`). If you intend to compile JavaScript files, ensure `allowJs: true` is set in your `tsconfig.json` or `createProject` options.
TS####: [TypeScript Compilation Error Message]
A TypeScript compilation error occurred, and `gulp-typescript` (since v5) is configured to crash the process on error in non-watch mode.
fix
Correct the TypeScript code identified by the error message. For development and watch mode, consider using `gulp-plumber` before the `tsProject()` pipe to prevent the stream from stopping on errors, allowing continuous watch and reporting.
Error: Input file must be a TS file!
Attempting to pass non-TypeScript files (e.g., JavaScript files) to the `gulp-typescript` stream without `allowJs` enabled in the compiler options.
fix
Either ensure `gulp.src` only selects `.ts` or `.tsx` files, or enable the `allowJs` option in your `tsconfig.json` or `ts.createProject` configuration if you intend to process JavaScript files.
Upgrade
Version history
6.0.0-alpha.1latest on npm
Audit
Dependencies
typescriptrequiredRequired as the underlying TypeScript compiler for processing TS files.
gulprequiredThe core task runner that gulp-typescript integrates with, specifically Gulp 4 and above.
Agent activity
41 hits · last 30 days
node
34
Amazon
1
OpenAI (training)
1
Resources
gulp-typescript — npm install gulp-typescript · libregistry