npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

yuku-strip

v0.5.4

Published

Fast TypeScript type stripping. Convert TypeScript to JavaScript by removing types.

Readme

yuku-strip

A high-performance TypeScript stripper. Removes type syntax from JavaScript and TypeScript source, returning runnable JavaScript. Powered by Yuku.

Install

npm install yuku-strip

Usage

import { strip } from "yuku-strip";
import { readFileSync } from "node:fs";

const { code, errors } = strip(readFileSync("example.ts", "utf8"));
console.log(code);
// example.ts

import { run, type Awaitable, type Result as Res } from "./api"

export type Unwrap<T> = T extends Awaitable<infer U> ? Unwrap<U> : T
export type Tagged<T> = { readonly [K in keyof T as `${string & K}$`]: T[K] }

class Store<T extends { id: `id_${string}` }> implements Iterable<T> {
  declare readonly index!: ReadonlyMap<T["id"], T>

  async load<R extends T = T>(id: T["id"]): Promise<R | null> {
    return (await run<R>(id))! satisfies R | null
  }

  *[Symbol.iterator](): IterableIterator<T> {
    for (const [, v] of this.index!) yield v
  }
}

function ensure<T, U extends T>(
  xs: readonly T[],
  is: (x: T) => x is U,
): asserts xs is readonly U[] {
  if (!xs.every(is)) throw new Error()
}

const fns = {
  ok: <const T>(v: T) => ({ tag: "ok" as const, v }),
  err: (r: string) => ({ tag: "err" as const, r }),
} satisfies Record<string, (...a: never[]) => Res<unknown>>

yuku-strip produces:

import { run } from "./api";
class Store {
  async load(id) {
    return (await run(id));
  }
  *[Symbol.iterator]() {
    for (const [, v] of this.index) yield v;
  }
}
function ensure(xs, is) {
  if (!xs.every(is)) throw new Error();
}
const fns = { ok: (v) => ({ tag: "ok", v }), err: (r) => ({ tag: "err", r }) };

How it works

Stripping is AST-based. The source is parsed once into a structured tree, and the codegen prints it back to JavaScript while skipping TypeScript-only nodes and fields. There is no regex, no whitespace overlay, no second pass.

That makes it always accurate and reliable. Every byte was already classified by the parser, and the stripper reads that classification directly. Nested template literal types, generic call expressions, conditional types, and every other awkward case are tree nodes like any other, not regex edge cases. And because parsing, stripping, and codegen all happen in native Zig in a single traversal, it is extremely fast. The JavaScript side only hands over the source string and reads back the result.

Options

const { code, errors } = strip(source, {
  sourceType: "module",
  lang: "ts",
  format: "pretty",
  indent: 2,
  quotes: "double",
});

| Option | Values | Default | Description | | -------------- | ----------------------------------------- | ---------- | ---------------------------------------------------------- | | sourceType | "module", "script" | "module" | Module mode enables import/export and strict mode | | lang | "ts", "tsx", "dts", "js", "jsx" | "ts" | Language variant of the input source | | format | "pretty", "compact" | "pretty" | Whitespace mode for the output | | indent | number | 2 | Spaces per level when format === "pretty" | | quotes | "double", "single" | "double" | Quote style for emitted string literals |

Result

interface StripResult {
  code: string;
  errors: Diagnostic[];
}

interface Diagnostic {
  message: string;
  start: number;
  end: number;
}

code is the stripped JavaScript output. errors is empty on a clean strip.

Note: yuku-strip does not yet return sourcemaps and has no sourcemap option. Sourcemap support is on the roadmap.

Path helpers

Two small helpers are exported for resolving the lang and sourceType options from a file path:

import { langFromPath, sourceTypeFromPath } from "yuku-strip";

langFromPath("foo.tsx");        // "tsx"
langFromPath("types.d.ts");     // "dts"
sourceTypeFromPath("foo.cjs");  // "script"
sourceTypeFromPath("foo.mjs");  // "module"

What stripping does not do

A few TypeScript features (enum, namespace, module, export =, import = require(), parameter properties) emit JavaScript runtime values. Converting them to JavaScript equivalents is a transpilation step, not a syntax-stripping step. yuku-strip does exactly what its name says, it strips TypeScript syntax. When a runtime-emitting construct is encountered, it is reported as a Diagnostic and skipped, and the rest of the file is still emitted.

A future Yuku transpiler will fill that role. It will lower these constructs to JavaScript and drive the codegen with stripping enabled in the same pass, giving fast, clean TypeScript-to-JavaScript output in a single pipeline.

All other TypeScript syntax (types, interfaces, type aliases, generics, type assertions, satisfies, non-null !, declare, abstract) strips cleanly today.

License

MIT