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

erasablefy

v0.1.1

Published

Codemod that rewrites TypeScript enum, value-namespace, and constructor parameter-properties into erasable syntax so your .ts files run directly on Node's type stripping (no build step, no ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX).

Readme

erasablefy

Rewrite the three TypeScript constructs that crash under Node's type stripping — enum, value namespace, and constructor parameter-properties — into equivalent erasable syntax, in place, with runtime behavior preserved.

npx erasablefy --write "src/**/*.ts"

The problem this solves

Node 24 LTS runs .ts files directly by stripping the types out. Node 26 went further and removed --experimental-transform-types (nodejs/node#61803) — the flag that used to compile enums and parameter-properties. There is no replacement and none is planned.

So the moment a module containing an enum, a value namespace, or a constructor(private x) actually executes, you get:

SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: Enum is not supported in strip-only mode

It passes tsc. It passes install. It blows up at runtime, on the one code path that touches the construct. tsc --erasableSyntaxOnly (TS 5.8) will flag every offender, but the fix has been manual up to now. erasablefy is the fix.

Before / after

// before — throws ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX under node --strip-types
enum Dir { Up, Down, Left, Right }

class Point {
  constructor(public readonly x: number, private y = 5) {}
}
// after — plain runtime code, strips cleanly, same behavior
const Dir = {
  "Up": 0, "Down": 1, "Left": 2, "Right": 3,
  "0": "Up", "1": "Down", "2": "Left", "3": "Right",
} as const;
type Dir = 0 | 1 | 2 | 3;

class Point {
  public readonly x: number;
  private y: number;
  constructor(x: number, y = 5) {
    this.x = x;
    this.y = y;
  }
}

Note the reverse-mapping keys ("2": "Left"). Numeric enums have them at runtime, so Dir[2] === "Left" keeps working — a naive as const object would silently drop that and change behavior. erasablefy keeps it.

What it rewrites

| Construct | Rewrite | | --- | --- | | enum (string, numeric, mixed) | as const object + value-union type, with numeric reverse mapping | | value namespace | const N = (() => { ... return {...} })() — keeps non-exported locals and closures | | constructor parameter-properties | explicit field declaration + assignment in the constructor body (after super()) |

What it refuses to touch (and tells you why)

A codemod that silently changes runtime behavior is worse than a manual fix. When erasablefy can't prove a transform is safe, it leaves the code alone and reports it:

  • const enum — inlined at each use site; the object form has different semantics
  • enum members with computed values (A = B << 1)
  • enums or namespaces that are merged across declarations
  • namespaces with a nested namespace, import =, or export =

Fix those by hand, or restructure and re-run.

Usage

# preview (default glob: src/**/*.ts)
npx erasablefy "src/**/*.ts"

# apply in place
npx erasablefy --write "src/**/*.ts"

# CI gate: exit 1 if anything still needs rewriting or manual review
npx erasablefy --check "src/**/*.ts"

Run your formatter afterward — erasablefy edits the AST and doesn't try to guess your Prettier config.

GitHub Action

Gate CI so no non-erasable syntax lands on a branch you run with node --strip-types:

# .github/workflows/erasable.yml
name: erasable-check
on: [push, pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: fernforge/erasablefy@v1
        with:
          globs: "src/**/*.ts"

Programmatic API

import { transformText, transformFiles } from "erasablefy";

const { code, result } = transformText(`enum E { A, B }`);
// result.changes  -> [{ kind: "enum", name: "E", line: 1 }]
// result.skips    -> [{ kind, name, line, reason }]

Scope

This handles the deterministic, mechanical rewrites. It does not resolve path aliases, emit decorator metadata, or bundle — if you rely on those you still need a build step (tsc, tsx, esbuild). It's aimed at the code that is otherwise ready to run on native type stripping and only trips on these three constructs.

License

MIT


Built autonomously by an AI agent.