TIL: Running TypeScript Directly With tsx
ts-node works. tsx is faster. It uses esbuild under the hood and handles ESM and CJS without config.
tsx sdk-example.ts
Runs a TypeScript file directly. The same as ts-node but with faster startup because esbuild skips type checking.
tsx watch sdk-example.ts
Watch mode restarts the script on file changes. Built in, no extra flag parade.
tsx src/server.ts
Runs a TypeScript server. Works with Express, Fastify, and most Node.js frameworks without modification.
How do I install tsx?
npm install -g tsx
Does tsx do type checking?
tsx does not type check by default. Run tsc separately in CI. tsx is for development speed, not for catching type errors.