A small, fast type-stripper that blanks TypeScript-only syntax using the oxc parser, leaving valid JavaScript with identical line and column positions.
npm install petreaFor browsers or platforms without a native binding, also install @petrea/wasm and import from petrea/wasm.
import { transpile } from 'petrea'
console.log(await transpile(`const a: number = 1`))
// result: `const a = 1`transpileSync offers a synchronous alternative to transpile.
import { transpileSync } from 'petrea'
console.log(transpileSync(`const a: number = 1`))
// result: `const a = 1`node --import petrea/register ./app.tspetrea/register hooks petrea into Node's module system, stripping types from
.ts/.tsx/.mts/.cts files as they load — both import and require().
Module format follows the nearest package.json type field.
MIT — © 2025-present Teages.
Published binaries embed oxc and
napi-rs (both MIT); bundled JavaScript dependencies are
listed in dist/THIRD-PARTY-LICENSES.md at build time.
The test suite's fixture corpus in test/fixture is derived from
ts-blank-space
(© 2024 Bloomberg Finance L.P.) and remains under the
Apache License 2.0.