tsx-strict is a CLI tool that runs TypeScript files with TSX while providing real-time type checking. It combines the speed of tsx with the safety of TypeScript's compiler, ensuring your code is both executable and type-safe.
- Real-time type checking: Runs TypeScript compiler alongside tsx for immediate feedback
- Watch mode: Automatically restarts on file changes
- Intelligent process management: Kills previous processes when recompilation starts
- Customizable compiler: Support for different TypeScript compiler versions
- Silent mode: Suppress output when needed
- Memory management: Configure Node.js memory limits
pnpm install -g tsx-strict
Or use with npx:
npx tsx-strict your-file.ts
tsx-strict app.ts
tsx-strict --watch app.ts
tsx-strict --no-type-check app.ts
Option | Description | Default |
---|---|---|
-w, --watch |
Enable watch mode | false |
--no-clear |
Do not clear screen | false |
--compiler |
Compiler path | typescript/bin/tsc |
--tsc-args <args...> |
Additional TypeScript compiler arguments | [] |
--tsx-args <args...> |
Additional tsx arguments | [] |
--silent |
Suppress output | false |
--no-type-check |
Skip type checking (run tsx directly) | false |
tsx-strict src/index.ts
tsx-strict --watch --tsc-args "--strict --exactOptionalPropertyTypes" src/app.ts
tsx-strict --silent --no-clear src/worker.ts
tsx-strict --no-type-check src/script.ts
tsx-strict runs two processes simultaneously:
- TypeScript Compiler (tsc): Performs type checking with
--noEmit
flag - tsx Runner: Executes the TypeScript file when compilation succeeds
The tool intelligently manages these processes, restarting tsx only when type checking passes and killing previous instances to prevent resource conflicts.
- Node.js >= 20.0.0
- tsx ^4.20.5 (peer dependency)
You can also use tsx-strict programmatically:
import { runTsxStrict } from "tsx-strict";
await runTsxStrict("src/app.ts", {
watch: true,
silent: false,
noClear: false,
compiler: "typescript/bin/tsc",
tscArgs: ["--strict"],
tsxArgs: [],
noTypeCheck: false,
});
tsx-strict provides clear error messages and exits gracefully on compilation errors. Type errors are displayed in real-time, and the tsx process only runs when compilation is successful.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
https://github.com/uanela/tsx-strict
Report issues at: https://github.com/uanela/tsx-strict/issues