ts-watch is a wrapper around the TypeScript compiler (tsc) that adds a --onSuccess COMMAND argument to run a command after every successful compilation. It is a fork of tsc-watch with fixes for macOS compatibility. Version 6.2.0 is the latest stable release, with periodic updates. Unlike raw tsc --watch, it provides lifecycle hooks (onSuccess, onFirstSuccess, onFailure, onCompilationComplete) to restart servers or run tests. It uses the locally installed TypeScript compiler and does not modify compilation behavior.
npm install ts-watchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Installs ts-watch, sets up a basic TypeScript project with a simple file, and demonstrates running ts-watch to watch for changes and execute the output on success.
If previously using tsc-watch, uninstall it: npm uninstall tsc-watch and install ts-watch: npm install --save-dev ts-watch. Then change all references in scripts from 'tsc-watch' to 'ts-watch'.
Ensure TypeScript is installed: npm install --save-dev typescript
Ensure your server process can be gracefully terminated. Use a process manager like 'wait-on' or 'concurrently' if needed.
Upgrade to latest: npm install --save-dev ts-watch@latest
Use npx ts-watch or add a script in package.json: "scripts": { "watch": "ts-watch ..." } then run npm run watch.Upgrade to ts-watch@>=6.0.5: npm install --save-dev ts-watch@latest
Use ts-watch as a CLI tool, not a library. Remove require('ts-watch') and use the command line.