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 🙏

© 2025 – Pkg Stats / Ryan Hefner

strip-ts

v0.0.1

Published

A TypeScript to JavaScript converter that strips TypeScript annotations while preserving functionality. Supports TypeScript (.ts/.tsx), Vue (.vue), and Svelte (.svelte) files.

Readme

strip-ts

A TypeScript to JavaScript converter that strips TypeScript annotations while preserving functionality. Supports TypeScript (.ts/.tsx), Vue (.vue), and Svelte (.svelte) files.

Features

  • Strips TypeScript type annotations, interfaces, and type aliases
  • Removes unused imports automatically
  • Preserves code formatting and comments
  • Supports React JSX/TSX files
  • Supports Vue Single File Components
  • Supports Svelte components
  • Handles type assertions and non-null assertions
  • Processes multiple files using glob patterns

Installation

npm install strip-ts

Usage

Programmatic API

The main function stripTS accepts file globs and options:

import { stripTS } from 'strip-ts';

// Process a single file
const result = await stripTS('src/components/Button.tsx', { outDir: 'dist' });

// Process multiple files with glob patterns
const results = await stripTS(['src/**/*.tsx', 'src/**/*.vue'], {
    outDir: 'dist',
    forceStrip: false,
    removeUnusedImports: true,
});

// Process all TypeScript files in a directory
const allResults = await stripTS('src/**/*.{ts,tsx,vue,svelte}', { outDir: 'dist' });

Options

interface StripTSOptions {
    /** Output directory for processed files (default: 'output') */
    outDir?: string;
    /** Force processing even if lang doesn't equal "ts" (for Vue files) (default: false) */
    forceStrip?: boolean;
    /** Remove unused imports after TypeScript stripping (default: true) */
    removeUnusedImports?: boolean;
}

String Processing

For processing TypeScript content as strings:

import { stripTSFromString } from 'strip-ts';

// Process a TypeScript string
const jsCode = await stripTSFromString(tsCode, 'tsx');

// Process a Vue string with options
const vueCode = await stripTSFromString(vueString, 'vue', {
    forceStrip: true,
    removeUnusedImports: false,
});

CLI Usage

# Process single file
npx strip-ts src/components/Button.tsx

# Process multiple files with globs
npx strip-ts "src/**/*.tsx" "src/**/*.vue"

# Force strip TypeScript from Vue files without lang="ts"
npx strip-ts --force-strip "src/**/*.vue"

Examples

TypeScript React Component

Input (Button.tsx):

import React from 'react';

interface ButtonProps {
    children: React.ReactNode;
    onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
    variant?: 'primary' | 'secondary';
}

function Button({ children, onClick, variant = 'primary' }: ButtonProps) {
    const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
        onClick?.(event);
    };

    return (
        <button className={`button button-${variant}`} onClick={handleClick}>
            {children}
        </button>
    );
}

export default Button;

Output (Button.jsx):

function Button({ children, onClick, variant = 'primary' }) {
    const handleClick = (event) => {
        onClick?.(event);
    };

    return (
        <button className={`button button-${variant}`} onClick={handleClick}>
            {children}
        </button>
    );
}

export default Button;

Vue Component

Input (Button.vue):

<template>
    <button v-if="!href" class="button" @click="handleClick">
        <slot />
    </button>
    <a v-else :href="href" class="button">
        <slot />
    </a>
</template>

<script lang="ts">
interface ButtonProps {
    href?: string;
    variant?: string;
}

export default {
    props: {
        href: {
            type: String as () => string,
            required: false,
        },
        variant: {
            type: String as () => string,
            default: 'primary',
        },
    },
    methods: {
        handleClick(event: MouseEvent): void {
            this.$emit('click', event);
        },
    },
};
</script>

Output (Button.vue):

<template>
    <button v-if="!href" class="button" @click="handleClick">
        <slot />
    </button>
    <a v-else :href="href" class="button">
        <slot />
    </a>
</template>

<script>
export default {
    props: {
        href: {
            type: String,
            required: false,
        },
        variant: {
            type: String,
            default: 'primary',
        },
    },
    methods: {
        handleClick(event) {
            this.$emit('click', event);
        },
    },
};
</script>

What Gets Removed

  • Type annotations (: string, : number, etc.)
  • Interface declarations (interface User { ... })
  • Type aliases (type Status = 'loading' | 'success')
  • Generic type parameters (useState<number>(0))
  • Type assertions (value as string)
  • Non-null assertions (value!)
  • Unused imports (when removeUnusedImports is true)

What Gets Preserved

  • Function and variable declarations
  • JSX/TSX syntax
  • Vue template and style sections
  • Svelte syntax and reactivity
  • Comments and formatting
  • Used imports
  • Runtime functionality