Tsickle is a TypeScript transpiler designed to convert TypeScript code into JavaScript with Closure Compiler-compatible JSDoc annotations and module formats (`goog.module`). It serves as an intermediate step in build pipelines that leverage Closure Compiler for advanced optimization and minification, particularly within large-scale applications like those developed by Google and Angular. The current stable version is 0.46.3, and its release cadence is irregular, tied to Angular's development and internal Google needs. Key differentiators include its specialized handling of TypeScript types for Closure's type system, conversion of ES6 modules to `goog.module`, and generation of externs.js from TypeScript definition files, making TypeScript projects amenable to the unique optimization strategies of Closure Compiler. It is explicitly noted as a library intended for integration into larger build systems rather than direct end-user application development, often requiring downstream compatibility with Closure's specific module and type conventions.
npm install tsickleVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the Tsickle CLI to transpile a simple TypeScript project, generating Closure-annotated JavaScript output in the `dist` directory. This setup includes a `tsconfig.json` and a `package.json` script for execution.
Migrate away from Tsickle. For Angular projects, the Angular CLI and `@angular/compiler-cli` handle Closure Compiler compatibility internally for many use cases, or explore alternative transpilation and optimization strategies.
Ensure that your downstream build tools and runtime environment (e.g., Closure Compiler) are configured to correctly consume and execute `goog.module` formatted code. Do not expect standard ES module output.
Treat Tsickle's output as an artifact that feeds directly into Closure Compiler, not as final source code to be manually inspected or debugged. Debug TypeScript source or Closure Compiler's final output.
Always install the exact or compatible TypeScript version specified in Tsickle's `peerDependencies`. Use `npm install typescript@~X.Y.Z` (where X.Y.Z is the required version).
Consistently use `declare` for interfaces, classes, and properties that interact with external systems or are part of a public API where name preservation is critical. Review Closure Compiler's externs and renaming policies.
Install the TypeScript version compatible with your Tsickle installation. For `tsickle@0.46.3`, run `npm install typescript@4.7.2`.
Review the `include`, `exclude`, and `paths` options in your `tsconfig.json`. Ensure all relevant `.ts` files and their dependencies are discoverable by the TypeScript compiler when Tsickle is run.
Run `npx tsickle --help` to view the available command-line options for your installed Tsickle version and update your build scripts accordingly.