Skip to Content
πŸ“– Guide DocumentsPlugin DevelopmentOverview

Plugin Development

For plugin authors β€” people writing new ttsc plugins. If you just want to use existing plugins like typia or @ttsc/lint, you don’t need this section. Go to TTSC Β· Using plugins instead.

This chapter is organized in three tiers:

Concepts

Background you need before authoring.

β†’ Concepts overview

  • Plugin protocol β€” the npm package contract and binary subcommands every ttsc plugin implements.
  • AST & Checker β€” how TypeScript-Go exposes the AST and Checker to Go plugins.

Authoring

The build-and-publish path.

β†’ Authoring overview

  • Getting started β€” smallest useful transform plugin, end to end.
  • Recipes β€” focused patterns you can copy.
  • Testing β€” Go unit tests + end-to-end ttsc fixtures.
  • Publishing β€” npm package shape and pre-publish checks.
  • Local development β€” go.work, gopls, go test, pnpm notes.

Reference

Deeper material β€” read as needed.

β†’ Reference overview

How a plugin works, in one paragraph

A ttsc plugin is an npm package with two halves: a JS descriptor that lives in the consumer’s node_modules and tells ttsc what the plugin does, and a Go transform that holds the actual logic. The Go transform reads the TypeScript-Go AST, queries the Checker, then either reports diagnostics or rewrites emit. It compiles once into a binary the first time it’s used, and the binary is cached. Plugins run everywhere ttsc runs β€” CLI, ttsx, ttscserver, every @ttsc/unplugin bundler adapter. One contract, one config (tsconfig.json’s compilerOptions.plugins).

Real code to read

Each first-party plugin is small enough to read end-to-end. Start with banner.

Test fixtures that bootstrap a Program for you:

Status

v1 protocol, still moving. Don’t publish ttsc as a peer dependency yet β€” treat it as a build-time-only dependency.

Requirements

  • Node.js 18+
  • Go 1.22+ (for go test / go vet)
  • A consumer test fixture with ttsc and @typescript/native-preview installed.
Last updated on