https://github.com/uanela/tsx-strict
Type-safe TSX runner with automatic Type-checking
https://github.com/uanela/tsx-strict
deno nodejs runner ts-node-dev tsx type-checking type-safe typescript
Last synced: 4 months ago
JSON representation
Type-safe TSX runner with automatic Type-checking
- Host: GitHub
- URL: https://github.com/uanela/tsx-strict
- Owner: Uanela
- License: mit
- Created: 2025-08-25T03:09:30.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-08-25T03:28:29.000Z (5 months ago)
- Last Synced: 2025-08-25T06:12:01.509Z (5 months ago)
- Topics: deno, nodejs, runner, ts-node-dev, tsx, type-checking, type-safe, typescript
- Language: TypeScript
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# `Tsx-Strict`
### Type-safe TSX runner with automatic type-checking
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.
## Features
- **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
## Installation
```bash
pnpm install -g tsx-strict
```
Or use with npx:
```bash
npx tsx-strict your-file.ts
```
## Usage
### Basic Usage
```bash
tsx-strict app.ts
```
### Watch Mode
```bash
tsx-strict --watch app.ts
```
### Skip Type Checking
```bash
tsx-strict --no-type-check app.ts
```
## CLI Options
| Option | Description | Default |
| ---------------------- | ---------------------------------------- | -------------------- |
| `-w, --watch` | Enable watch mode | `false` |
| `--no-clear` | Do not clear screen | `false` |
| `--compiler` | Compiler path | `typescript/bin/tsc` |
| `--tsc-args ` | Additional TypeScript compiler arguments | `[]` |
| `--tsx-args ` | Additional tsx arguments | `[]` |
| `--silent` | Suppress output | `false` |
| `--no-type-check` | Skip type checking (run tsx directly) | `false` |
## Examples
### Basic TypeScript File
```bash
tsx-strict src/index.ts
```
### Watch Mode with Custom TSC Arguments
```bash
tsx-strict --watch --tsc-args "--strict --exactOptionalPropertyTypes" src/app.ts
```
### Silent Mode
```bash
tsx-strict --silent --no-clear src/worker.ts
```
### Skip Type Checking for Quick Execution
```bash
tsx-strict --no-type-check src/script.ts
```
## How It Works
tsx-strict runs two processes simultaneously:
1. **TypeScript Compiler (tsc)**: Performs type checking with `--noEmit` flag
2. **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.
## Requirements
- Node.js >= 20.0.0
- tsx ^4.20.5 (peer dependency)
## API
You can also use tsx-strict programmatically:
```typescript
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,
});
```
## Error Handling
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.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
MIT
## Repository
[https://github.com/uanela/tsx-strict](https://github.com/uanela/tsx-strict)
## Issues
Report issues at: [https://github.com/uanela/tsx-strict/issues](https://github.com/uanela/tsx-strict/issues)