
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
bare-type-stripper
Advanced tools
Heuristic lexer for stripping TypeScript type syntax to produce plain JavaScript
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.
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] }
// '
See the bare-type-stripper reference.
| 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 |
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.constructor(public x: number) implies a this.x = x assignment that stripping the modifier would silently lose.<Foo>expr) - indistinguishable from JSX, which is not supported.The stripper targets plain .ts sources; JSX (.tsx) is not supported and is reported as non-erasable syntax.
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.
Apache-2.0
FAQs
Heuristic lexer for stripping TypeScript type syntax to produce plain JavaScript
The npm package bare-type-stripper receives a total of 17,979 weekly downloads. As such, bare-type-stripper popularity was classified as popular.
We found that bare-type-stripper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.