Skip to content
nuxt-contribPublic

About

A small, fast type-stripper that blanks TypeScript-only syntax using the oxc parser

Resources

Stars

7 stars

Watchers

0 watching

Forks

Repository files navigation

petrea

A small, fast type-stripper that blanks TypeScript-only syntax using the oxc parser, leaving valid JavaScript with identical line and column positions.

Install

npm install petrea

For browsers or platforms without a native binding, also install @petrea/wasm and import from petrea/wasm.

Getting Started

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`

Run TypeScript directly in Node

node --import petrea/register ./app.ts

petrea/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.

License

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.

About

A small, fast type-stripper that blanks TypeScript-only syntax using the oxc parser

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages