typescript-closure-compiler
raw JSON → 1.8.11 verified Fri May 01 auth: no javascript abandoned
Patches the TypeScript compiler to generate JSDoc annotations for Google Closure Compiler integration. Stable version 1.8.11 is compatible with TypeScript 1.8.10. Release cadence matches TypeScript major.minor versions. This package is a niche tool specifically for combining TypeScript with Closure Compiler's advanced optimizations, unlike general-purpose TypeScript compilers. It provides a CLI command `tscc` that replaces `tsc` and adds options for entry points, exports, and externs. Not actively maintained; last release in 2016. Users should be aware of TypeScript version lock-in and potential issues with modern TypeScript features.
Common errors
error Error: Cannot find module 'typescript' ↓
cause typescript-closure-compiler requires TypeScript 1.8.10 installed in the same directory or globally.
fix
Run 'npm install -g typescript@1.8.10' alongside typescript-closure-compiler.
error error TS5023: Unknown compiler option 'externs'. ↓
cause Using typescript-closure-compiler (tscc) instead of tsc? The option 'externs' is only supported by tscc.
fix
Use 'tscc' command instead of 'tsc' when employing package-specific options.
Warnings
breaking Package is compatible only with TypeScript 1.8.10. Using with newer TypeScript versions will likely break. ↓
fix Pin to TypeScript 1.8.x; do not upgrade TypeScript without upgrading this package.
deprecated Project appears abandoned; last release 2016, no updates since. ↓
fix Consider alternatives like tsickle or direct Closure Compiler usage.
gotcha The --module flag is only for compilation; modules are not preserved in output because all code is bundled into one file. ↓
fix Do not rely on module syntax in output; code will be concatenated into a single file without module wrappers.
Install
npm install typescript-closure-compiler yarn add typescript-closure-compiler pnpm add typescript-closure-compiler Imports
- tscc wrong
npm install -g typescript-closure-compiler && tscc app.tscorrectnpx tscc app.ts - default export (none) wrong
import { compile } from 'typescript-closure-compiler'correctNo programmatic API exposed; use CLI or gulp plugin. - gulp-typescript-closure-compiler wrong
import gulpTscc from 'typescript-closure-compiler'correctconst gulpTscc = require('gulp-typescript-closure-compiler')
Quickstart
// Install globally
npm install -g typescript-closure-compiler
// Compile a TypeScript file
tscc app.ts
// With options: entry point and export name
tscc app.ts --module commonjs --entry app.ts --exportAs App
// Using tsconfig.json with externs
// tsconfig.json:
{
"compilerOptions": { "module": "commonjs" },
"files": ["app.ts"],
"externs": ["externs/app-externs.d.ts"],
"externsOutFile": "externs.js"
}
// Then run:
tscc --project .