Skip to Content

Local Plugin Development

Consumers do not need Go installed. Plugin authors usually do, because direct go test, go vet, and gopls feedback are much faster than running ttsc for every edit.

Basic Loop

For a check plugin that does not import TypeScript-Go shims:

go test ./go-plugin/... go vet ./go-plugin/... go build ./go-plugin

That is enough for simple diagnostics plugins. Transform plugins usually import the ttsc driver or TypeScript-Go shims.

Shim-Using Plugins

If your plugin imports github.com/microsoft/typescript-go/shim/..., add ttsc as a dev dependency:

npm i -D ttsc

Then create go.work at the plugin repo root:

go 1.26 use ( ./go-plugin ./node_modules/ttsc ./node_modules/ttsc/shim/ast ./node_modules/ttsc/shim/bundled ./node_modules/ttsc/shim/checker ./node_modules/ttsc/shim/compiler ./node_modules/ttsc/shim/core ./node_modules/ttsc/shim/diagnosticwriter ./node_modules/ttsc/shim/parser ./node_modules/ttsc/shim/printer ./node_modules/ttsc/shim/scanner ./node_modules/ttsc/shim/tsoptions ./node_modules/ttsc/shim/tspath ./node_modules/ttsc/shim/vfs ./node_modules/ttsc/shim/vfs/cachedvfs ./node_modules/ttsc/shim/vfs/osvfs )

You can list only the shims you use. Listing all is harmless and keeps editor setup simple.

go.mod

Every imported shim still needs a require line:

require github.com/microsoft/typescript-go/shim/ast v0.0.0

The go.work file tells Go where v0.0.0 lives locally. The plugin go.mod keeps require lines for imported host modules, and the installed ttsc package owns github.com/samchon/ttsc/packages/ttsc, github.com/microsoft/typescript-go, and github.com/microsoft/typescript-go/shim/.... Printer, AST, and other plugin helper code belongs under the plugin’s own module path while importing the ttsc-supplied shims.

pnpm

The go.work above assumes ./node_modules/ttsc exists. With pnpm’s isolated linker it may not.

Recommended for plugin development repos:

# .npmrc node-linker=hoisted

Alternative:

public-hoist-pattern[]=ttsc

This affects only your plugin repo’s development layout. Published plugins still work in consumer projects with npm, pnpm, yarn, or other package managers.

Ignore

Commit go.work; ignore machine-specific data:

node_modules/ go.work.sum

After a ttsc Upgrade

Run:

npm update ttsc go test ./go-plugin/... go vet ./go-plugin/...

If TypeScript-Go moved a shim symbol you use, the Go compile error points at the exact call site.

For this repository’s workspace build, test, platform package, and release commands, see Workspace Release.

Next

Reference · Architecture — internals and the wider picture.

Last updated on