The live compiler patches on-the-fly, each time it is run.
Via commandline: Simply use tspc (instead of tsc)
With tools such as ts-node, webpack, ts-jest, etc: specify the compiler as ts-patch/compiler
Additional live routes are available for tools that need a specific TypeScript entry:
Route
Library identity supplied to transformers
ts-patch/compiler
typescript
ts-patch/compiler/typescript
typescript
ts-patch/compiler/tsc
tsc
ts-patch/compiler/tsserver
tsserver
ts-patch/compiler/tsserverlibrary
tsserverlibrary
Method 2: Persistent Patch
Persistent patching modifies supported TypeScript files inside node_modules. It is still available for TypeScript 6,
but the patchable surface is narrower than it was in earlier TypeScript versions.
TypeScript 6 ships thin entry shims for several library files. Some service entries delegate to shared implementation
files; for example, tsserverlibrary.js delegates to typescript.js. Rewriting those service files in place would not
preserve enough entry context to distinguish direct compiler API use from tsc, tsserver, or tsserverlibrary use.
For those entries, use the live compiler routes instead.
install and uninstall remain available, but they now affect only typescript.js and tsc.js:
ts-patch installts-patch uninstall
The lower-level patch and unpatch commands are also limited to those two targets:
tsserver.js and tsserverlibrary.js are not persistent patch targets on TypeScript 6. Use the live routes above so
transformers still receive the correct library identity for those service entries.
Configuration
tsconfig.json: Add transformers to compilerOptions in plugins array.
Diagnostics can be altered in a Source Transformer.
To alter diagnostics you can use the following, provided from the TransformerExtras parameter:
property
description
diagnostics
Reference to Diagnostic array
addDiagnostic()
Safely add Diagnostic to diagnostics array
removeDiagnostic()
Safely remove Diagnostic from diagnostics array
Note
This alters diagnostics during emit only. If you want to alter diagnostics in your IDE as well, you'll need to create a LanguageService plugin to accompany your source transformer
Program Transformers
Sometimes you want to do more than just transform source code. For example you may want to:
TypeCheck code after it's been transformed
Generate code and add it to the program
Add or remove emit files during transformation
For this, we've introduced what we call a Program Transformer. The transform action takes place during ts.createProgram, and allows
re-creating the Program instance that typescript uses.
The plugin package configuration allows you to specify custom options for your TypeScript plugin.
This configuration is defined in the package.json of your plugin under the tsp property.
An example use case is enabling parseAllJsDoc if you require full JSDoc parsing in tsc for your transformer in TS v5.3+. (see: 5.3 JSDoc parsing changes)
For all available options, see the PluginPackageConfig type in plugin-types.ts
Skips patch cache when patching via cli or live compiler.
(env) TSP_COMPILER_TS_PATH
Specify typescript library path to use for ts-patch/compiler (defaults to require.resolve('typescript'))
(env) TSP_CACHE_DIR
Override patch cache directory
(cli) ts-patch clear-cache
Cleans patch cache & lockfiles
Compatibility Direction
TypeScript 6 changed the compiler distribution shape by introducing thin CommonJS shims around several implementation
files. ts-patch uses live routing where entry identity matters because a live route can preserve whether a tool requested
typescript, tsc, tsserver, or tsserverlibrary without permanently rewriting service-entry shims.
For TypeScript 6, persistent patching is intentionally narrow: only typescript.js and tsc.js are patchable targets.
Service entries should be loaded through ts-patch/compiler/tsserver or ts-patch/compiler/tsserverlibrary.
The TypeScript team has also announced a future Go-based compiler line. ts-patch will evaluate that implementation as a
separate compatibility track, including whether the JavaScript compiler API and transformer hooks remain available or
whether a redesigned integration is required.