Browserify plugin for compiling TypeScript files with seamless integration and incremental compilation support
—
Core internal classes and methods that make up tsify's TypeScript compilation engine.
Main compilation orchestrator that manages TypeScript compilation and caching.
/**
* Main TypeScript compilation orchestrator
* @param opts - Parsed TypeScript compiler options
* @param bopts - Browserify options
*/
class Tsifier extends EventEmitter {
constructor(opts: any, bopts: any);
/** Reset compilation state and clear caches */
reset(): void;
/** Generate compilation cache for given files */
generateCache(files: string[], ignoredFiles?: string[]): void;
/** Add files to compilation scope */
addFiles(files: string[]): void;
/** Perform TypeScript compilation */
compile(): void;
/** Check syntax errors in program */
checkSyntax(program: any): any[];
/** Check semantic errors in program */
checkSemantics(program: any): any[];
/** Transform stream for processing files */
transform(file: string, data: string): any;
}Usage Example:
const { Tsifier } = require('tsify/lib/Tsifier')(require('typescript'));
// Tsifier is used internally by the main plugin function
// Not typically used directly by consumersVirtual file system implementation that manages TypeScript source files in memory.
/**
* TypeScript compiler host implementation
* @param currentDirectory - Base directory for compilation
* @param opts - TypeScript compiler options
*/
class Host extends EventEmitter {
constructor(currentDirectory: string, opts: any);
/** Reset file cache and increment version */
_reset(): void;
/** Add file to virtual file system */
_addFile(filename: string, root?: boolean): void;
/** Compile TypeScript program */
_compile(opts: any): any;
/** Get canonical file name (handles case sensitivity) */
getCanonicalFileName(filename: string): string;
/** Check if file exists in virtual file system */
fileExists(filename: string): boolean;
/** Read file from virtual file system */
readFile(filename: string): string;
/** Get source file from compilation */
getSourceFile(filename: string, languageVersion: any): any;
/** Write compiled output */
writeFile(filename: string, data: string): void;
/** Get current directory */
getCurrentDirectory(): string;
/** Get new line character */
getNewLine(): string;
/** Check if file name casing is correct */
useCaseSensitiveFileNames(): boolean;
}Error class for TypeScript compilation errors with detailed diagnostic information.
/**
* TypeScript compilation error with detailed diagnostics
* @param diagnostic - TypeScript diagnostic object
*/
class CompileError extends SyntaxError {
constructor(diagnostic: any);
/** File name where error occurred */
fileName?: string;
/** Line number of error */
line?: number;
/** Column number of error */
column?: number;
/** Error name */
name: string;
/** Formatted error message */
message: string;
}Error Message Format:
filename.ts(line,column): category TS#### error messageUsage Example:
browserify()
.add('main.ts')
.plugin(tsify)
.bundle()
.on('error', function(error) {
if (error instanceof CompileError) {
console.log('File:', error.fileName);
console.log('Location:', error.line + ':' + error.column);
console.log('Message:', error.message);
}
});Internal utility functions for determining file types.
/** Check if file is TypeScript */
function isTypescript(file: string): boolean;
/** Check if file is TSX */
function isTsx(file: string): boolean;
/** Check if file is JavaScript */
function isJavascript(file: string): boolean;
/** Check if file is TypeScript declaration */
function isTypescriptDeclaration(file: string): boolean;/** Replace file extension */
function replaceFileExtension(file: string, extension: string): string;
/** Check if file exists on disk */
function fileExists(file: string): boolean;interface ParsedOptions {
/** TypeScript compiler options */
options: any;
/** Array of file names to compile */
fileNames: string[];
}
interface TsifierInstance {
/** Parsed TypeScript options */
opts: any;
/** Files to compile */
files: string[];
/** Files to ignore */
ignoredFiles: string[];
/** Browserify options */
bopts: any;
/** Compiler host instance */
host: Host;
}Install with Tessl CLI
npx tessl i tessl/npm-tsify