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

type-thief

v0.1.1

Published

Automatically generate TypeScript types from your backend API responses and runtime data with zero effort. No more manual type creation!

Downloads

6

Readme

🔍 type-thief

Automatically generate TypeScript types from your runtime data with zero effort! Perfect for creating type definitions from API responses without writing them manually.

🌟 Why type-thief?

Tired of manually creating TypeScript interfaces for your API responses? type-thief solves this problem by automatically generating accurate type definitions from your runtime data:

  • Save time - No more tedious manual type creation
  • Stay in sync - Types always match your actual API responses
  • Zero dependencies - Lightweight addition to your project
  • Smart type inference - Handles nested objects, arrays, and relationships

⚡ Quick Start

import { thief } from 'type-thief';

// Generate a type from a simple object
const user = { name: 'John', age: 30 };
thief(user, { typeName: 'User', fileName: 'user.ts' });

// Result in types/user.ts:
// export type User = { name: string; age: number };

🚀 Next.js Example: Todo App

Here's how to use Type Thief in a Next.js application to generate types for your API data:

// app/page.tsx
import { thief } from 'type-thief';

async function getTodos() {
  // Fetch a single todo first
  const singleRes = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  const singleTodo = await singleRes.json();
  
  // Generate the Todo type
  await thief(singleTodo, {
    typeName: 'Todo',
    outputDir: 'types',
    fileName: 'todo.ts',
    debug: true
  });
  
  // Then fetch all todos
  const todosRes = await fetch('https://jsonplaceholder.typicode.com/todos');
  const todos = await todosRes.json();
  
  // Generate the Todos type - it will automatically use Todo[] if structures match
  await thief(todos, {
    typeName: 'Todos',
    outputDir: 'types',
    fileName: 'todo.ts',
    debug: true
  });
  
  return todos;
}

export default async function Home() {
  const todos = await getTodos();

  return (
    <main className="p-8">
      <h1 className="text-2xl font-bold mb-4">Todos</h1>
      <ul className="space-y-2">
        {todos.slice(0, 5).map((todo) => (
          <li key={todo.id} className="p-4 border rounded">
            <span className={`${todo.completed ? 'line-through text-green-600' : 'text-red-600'}`}>
              {todo.title}
            </span>
          </li>
        ))}
      </ul>
    </main>
  );
}

This will generate the following types in types/todo.ts:

export type Todo = {
  userId: number;
  id: number;
  title: string;
  completed: boolean;
};

export type Todos = Todo[];

Notice how the Todos type automatically references the existing Todo type instead of duplicating the structure!

💡 Common Use Cases

  • API Integration: Generate types from REST or GraphQL API responses
  • Backend Communication: Keep frontend types in sync with your backend data
  • Prototyping: Quickly build type-safe applications without writing types manually
  • Data Exploration: Understand the structure of complex data by generating types

🛠️ Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | typeName | string | 'GeneratedType' | Name of the generated type | | outputDir | string | 'types' | Directory where type files are saved | | fileName | string | 'generated.ts' | Name of the output file | | debug | boolean | false | Enable debug logging |

✨ Features

  • 🔄 Automatically detects arrays and generates appropriate types
  • 🧩 Reuses existing types when possible
  • 📝 Preserves existing type definitions
  • 🔍 Smart type inference for nested objects and arrays
  • 🌟 Special handling for common patterns like Todo/Todos
  • 📦 Zero dependencies - lightweight and fast

📦 Installation

npm install type-thief
# or
yarn add type-thief
# or
pnpm add type-thief