
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
Automatically generate TypeScript types from your backend API responses and runtime data with zero effort. No more manual type creation!
Automatically generate TypeScript types from your runtime data with zero effort! Perfect for creating type definitions from API responses without writing them manually.
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:
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 };
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!
| 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 |
npm install type-thief
# or
yarn add type-thief
# or
pnpm add type-thief
FAQs
Automatically generate TypeScript types from your backend API responses and runtime data with zero effort. No more manual type creation!
The npm package type-thief receives a total of 15 weekly downloads. As such, type-thief popularity was classified as not popular.
We found that type-thief demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.