or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

compilation.mdconfiguration.mdindex.mdprojects.mdreporters.mdstreams.md
tile.json

index.mddocs/

Gulp TypeScript

Gulp TypeScript is a comprehensive TypeScript compiler plugin for the gulp build system that enables incremental compilation, source map support, and flexible configuration options. It exposes TypeScript's compiler API to gulp workflows, allowing developers to compile TypeScript files with full control over compiler options including target ECMAScript versions, module systems, declaration file generation, and custom transformers.

Package Information

  • Package Name: gulp-typescript
  • Package Type: npm
  • Language: TypeScript
  • Installation:
    npm install gulp-typescript typescript

Core Imports

import * as ts from 'gulp-typescript';

For CommonJS:

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

Basic Usage

import * as gulp from 'gulp';
import * as ts from 'gulp-typescript';

// Basic compilation
gulp.task('compile', () => {
    return gulp.src('src/**/*.ts')
        .pipe(ts({
            noImplicitAny: true,
            outDir: 'dist'
        }))
        .pipe(gulp.dest('dist'));
});

// Project-based compilation with incremental builds
const tsProject = ts.createProject('tsconfig.json');

gulp.task('compile-project', () => {
    return gulp.src('src/**/*.ts')
        .pipe(tsProject())
        .pipe(gulp.dest('dist'));
});

// Separate JavaScript and declaration outputs
gulp.task('compile-separate', () => {
    const tsResult = gulp.src('src/**/*.ts')
        .pipe(tsProject());
    
    return merge([
        tsResult.js.pipe(gulp.dest('dist/js')),
        tsResult.dts.pipe(gulp.dest('dist/types'))
    ]);
});

Architecture

Gulp TypeScript is built around several key components:

  • Main Compilation Function: Primary
    compile
    function with multiple overloads for different usage patterns
  • Project System:
    createProject
    for reusable compilation configurations and incremental builds
  • Stream Interface: Integration with gulp's streaming build system via readable/writable streams
  • Compiler Implementations: ProjectCompiler for full type checking, FileCompiler for isolated module compilation
  • Error Reporting: Configurable reporter system for handling compilation errors and results
  • File Caching: Incremental compilation support through intelligent file change detection
  • TypeScript Integration: Direct integration with TypeScript compiler API for maximum compatibility

Capabilities

Core Compilation

Primary compilation functionality for transforming TypeScript files into JavaScript with full compiler option support.

function compile(proj: Project, theReporter?: Reporter): CompileStream;
function compile(settings: Settings, theReporter?: Reporter): CompileStream;
function compile(): CompileStream;

function filter(...args: any[]): void;

Core Compilation

Project Management

Project creation and management for incremental compilation and configuration reuse.

function createProject(tsConfigFileName: string, settings?: Settings): Project;
function createProject(settings?: Settings): Project;

interface Project {
    (reporter?: Reporter): ICompileStream;
    src(): NodeJS.ReadWriteStream;
    readonly typescript?: typeof ts;
    readonly projectDirectory: string;
    readonly configFileName: string;
    readonly rawConfig: any;
    readonly config: TsConfig;
    readonly options: ts.CompilerOptions;
    readonly projectReferences: ReadonlyArray<ts.ProjectReference> | undefined;
}

Project Management

Error Reporting

Comprehensive error reporting system with multiple reporter types for different output formats and integration scenarios.

interface Reporter {
    error?: (error: TypeScriptError, typescript: typeof ts) => void;
    finish?: (results: CompilationResult) => void;
}

function nullReporter(): Reporter;
function defaultReporter(): Reporter;
function longReporter(): Reporter;
function fullReporter(fullFilename?: boolean): Reporter;

Error Reporting

Configuration Options

Complete TypeScript compiler configuration with gulp-specific extensions and deprecated option handling.

interface Settings {
    out?: string;
    outFile?: string;
    outDir?: string;
    allowNonTsExtensions?: boolean;
    charset?: string;
    codepage?: number;
    declaration?: boolean;
    locale?: string;
    mapRoot?: string;
    noEmitOnError?: boolean;
    noImplicitAny?: boolean;
    noLib?: boolean;
    noLibCheck?: boolean;
    noResolve?: boolean;
    preserveConstEnums?: boolean;
    removeComments?: boolean;
    suppressImplicitAnyIndexErrors?: boolean;
    target?: string | ts.ScriptTarget;
    module?: string | ts.ModuleKind;
    moduleResolution?: string | number;
    jsx?: string | number;
    declarationFiles?: boolean;
    noExternalResolve?: boolean;
    sortOutput?: boolean;
    getCustomTransformers?: GetCustomTransformers;
    typescript?: typeof ts;
    isolatedModules?: boolean;
    rootDir?: string;
    rootDirs?: any;
    lib?: string[];
    experimentalDecorators?: boolean;
    sourceRoot?: string;
    [name: string]: any;
}

Configuration

Stream Interface

Gulp stream integration with separate JavaScript and declaration file outputs for flexible build pipeline integration.

interface ICompileStream extends NodeJS.ReadWriteStream {
    js: stream.Readable;
    dts: stream.Readable;
}

Stream Interface

Types

type CompileStream = ICompileStream;

interface CompilationResult {
    transpileErrors: number;
    optionsErrors: number;
    syntaxErrors: number;
    globalErrors: number;
    semanticErrors: number;
    declarationErrors: number;
    emitErrors: number;
    noEmit: boolean;
    emitSkipped: boolean;
}

interface TypeScriptError extends Error {
    fullFilename?: string;
    relativeFilename?: string;
    diagnostic: ts.Diagnostic;
    startPosition?: {
        position: number;
        line: number;
        character: number;
    };
    endPosition?: {
        position: number;
        line: number;
        character: number;
    };
}

type GetCustomTransformers = string | ((program?: ts.Program) => ts.CustomTransformers | undefined);

interface TsConfig {
    files?: string[];
    include?: string[];
    exclude?: string[];
    compilerOptions?: any;
}