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

bare-type-stripper

v0.1.7

Published

Heuristic lexer for stripping TypeScript type syntax to produce plain JavaScript

Readme

bare-type-stripper

Heuristic lexer for stripping TypeScript type syntax to produce plain JavaScript. Stripped regions are replaced with spaces so source positions and line numbers are preserved.

Usage

const strip = require('bare-type-stripper')

strip(`
  const x: number = 1
  function f<T>(xs: T[]): T { return xs[0] }
`).toString()

// '
//   const x         = 1
//   function f   (xs   )    { return xs[0] }
// '

API

See the bare-type-stripper reference.

What gets stripped

| Construct | Example | | :------------------------ | :------------------------------------ | | Type annotations | const x: number = 1 | | Type aliases | type Foo = number | | Interfaces | interface Foo { x: number } | | Type-only imports/exports | import type { Foo } from 'mod' | | Generics at declarations | function f<T>(x: T): T | | Generics at call sites | foo<number>() | | Generic arrow functions | <T>(x: T) => x | | Type assertions | x as Foo, x satisfies Foo | | Non-null assertion | obj!.foo | | Optional parameter marker | function f(x?: T) | | Definite assignment | let x!: number | | Class member modifiers | public, private, readonly, etc. | | implements clauses | class C implements I | | declare statements | declare const x: number | | Overload signatures | function f(x: string): void | | Abstract members | abstract foo(): void |

What is left alone

  • Decorators - they emit runtime code and are valid JavaScript syntax.

What throws

Constructs with runtime semantics that a purely lexical stripper cannot reproduce are marked with the ERROR flag, and strip() throws a SyntaxError when it meets one:

  • enum / const enum declarations - they emit a runtime object.
  • namespace / module declarations with bodies - they emit runtime code.
  • Parameter properties - constructor(public x: number) implies a this.x = x assignment that stripping the modifier would silently lose.
  • Old-style angle-bracket type assertions (<Foo>expr) - indistinguishable from JSX, which is not supported.

Limitations

The stripper targets plain .ts sources; JSX (.tsx) is not supported and is reported as non-erasable syntax.

Threat model

bare-type-stripper is one of the addons Bare compiles into its binary, so it inherits Bare's threat model. See docs/threat-model.md for where this addon sits in it.

License

Apache-2.0