tsnt

raw JSON →
1.0.0 verified Fri May 01 auth: no javascript

tsnt is a zero-config CLI tool for transpiling TypeScript to JavaScript without performing type checking. Version 1.0.0 provides fast transpilation by skipping type checks entirely, making it suitable for development workflows where type checking is done separately. Unlike tsc or ts-node, tsnt focuses solely on transpilation speed and simplicity. It is distributed as an npm package with a single command-line interface.

error SyntaxError: Cannot use import statement outside a module
cause Running TypeScript file directly with Node.js without transpilation.
fix
Use npx tsnt file.ts to transpile first, then run node file.js
error Error: No input files found.
cause Provided glob pattern did not match any .ts files.
fix
Check the glob pattern: tsnt 'src/**/*.ts' (quote it in shell)
gotcha tsnt skips type checking entirely. Type errors in source code will not cause transpilation to fail.
fix Use tsc --noEmit or an IDE plugin for type checking separately.
breaking Version 1.0.0 drops support for CommonJS require() in Node.js. Only ESM imports are allowed.
fix Use import syntax or upgrade to Node.js 14+ with 'type': 'module'.
gotcha tsnt transpiles using the latest TypeScript features by default, not the target version in tsconfig.json.
fix Use --target ES2020 to specify the output JS version.
deprecated The function `tsnt` default export will be renamed to `transpileTs` in v2.0.0.
fix Use named import `{ transpile }` moving forward.
npm install tsnt
yarn add tsnt
pnpm add tsnt

Shows basic CLI usage: transpile a single file and a glob pattern with output directory.

npx tsnt myfile.ts
# Transpile a single file
tsnt src/**/*.ts --outDir dist