New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

typeweaver

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeweaver

Stop manually syncing types between your backend and frontend. Auto-generate TypeScript types from your ORM schemas.

latest
Source
npmnpm
Version
1.1.3
Version published
Weekly downloads
31
158.33%
Maintainers
1
Weekly downloads
 
Created
Source

🧵 TypeWeaver

Stop manually syncing types between your backend and frontend.

Auto-generate TypeScript interfaces from your ORM schemas in real-time.

npm version License: MIT

🔥 The Problem

Full-stack TypeScript developers face a daily problem:

// Backend: Update User model
const userSchema = new Schema({
  name: String,
  email: String,
  phoneNumber: String, // ← NEW FIELD
});

// Frontend: Types are now OUT OF SYNC ❌
interface User {
  name: string;
  email: string;
  // Missing phoneNumber!
}

// Result: Runtime bugs that TypeScript should have caught

The consequences:

  • ⏰ 30+ minutes per week manually copying types
  • 🐛 Type mismatches cause production bugs
  • 🔄 Constant context switching between backend/frontend
  • 😤 Forgotten updates slip through code reviews

✨ The Solution

# One-time setup
npx typeweaver init

# Generate types once
npx typeweaver generate

# Or watch mode (auto-sync on every change)
npx typeweaver watch

That's it. Your frontend types stay in sync automatically.

🚀 Quick Start

Run locally (Windows PowerShell)

If you're on Windows and using PowerShell, here are copy/paste-friendly commands:

# install deps
npm install

# interactive setup
npx typeweaver init

# generate types once
npx typeweaver generate

# watch mode
npx typeweaver watch

# run tests
npm test

# run dev CLI
npm run dev

Installation

npm install -D typeweaver

Setup (Interactive)

npx typeweaver init

This creates typeweaver.config.json:

{
  "orm": "prisma",
  "schemaPath": "./prisma/schema.prisma",
  "outputPath": "./types",
  "outputMode": "single"
}

Generate Types

# One-time generation
npx typeweaver generate

# Watch mode (auto-regenerate on changes)
npx typeweaver watch

📋 Features

✅ Supported ORMs

ORMStatusDescription
PrismaReadyParse schema.prisma files
MongooseReadyParse Schema definitions
TypeORM🚧 Coming SoonParse decorators
Sequelize🚧 Coming SoonParse models

✨ Key Features

  • Zero Migration - Works with your existing code
  • Real-Time Sync - Watch mode updates types instantly (<500ms)
  • Safe Writes - Automatic backups before overwriting
  • Multi-ORM - Prisma, Mongoose, and more
  • Flexible Output - Single file or one file per model
  • Type-Safe - Handles complex types, enums, arrays, references
  • Smart Detection - Auto-detects your ORM

📖 Usage Examples

Prisma

// schema.prisma
model User {
  id    String @id @default(cuid())
  email String @unique
  name  String
  age   Int?
  posts Post[]
}

model Post {
  id      String @id
  title   String
  content String?
  author  User   @relation(fields: [authorId], references: [id])
  authorId String
}

Generated TypeScript:

// types/index.ts
export interface User {
  id: string;
  email: string;
  name: string;
  age?: number | null;
  posts: string[];
}

export interface Post {
  id: string;
  title: string;
  content?: string | null;
  author: string;
  authorId: string;
}

Mongoose

// models/User.js
const userSchema = new Schema({
  name: { type: String, required: true },
  email: { type: String, required: true },
  age: Number,
  role: { type: String, enum: ["user", "admin"] },
  posts: [{ type: Schema.Types.ObjectId, ref: "Post" }],
});

Generated TypeScript:

// types/index.ts
export interface User {
  name: string;
  email: string;
  age?: number | null;
  role: "user" | "admin";
  posts: string[];
}

⚙️ Configuration

Config File (typeweaver.config.json)

{
  "orm": "auto",
  "modelsPath": "./models",
  "schemaPath": "./prisma/schema.prisma",
  "outputPath": "./types",
  "outputMode": "single",
  "watch": false,
  "includeComments": true,
  "exclude": ["**/node_modules/**", "**/*.test.{js,ts}"]
}

Configuration Options

OptionTypeDefaultDescription
ormstring"auto"ORM to use: auto, prisma, mongoose
modelsPathstring"./models"Path to Mongoose models
schemaPathstring"./prisma/schema.prisma"Path to Prisma schema
outputPathstring"./types"Where to generate types
outputModestring"single"single file or separate files
watchbooleanfalseEnable watch mode
includeCommentsbooleantrueInclude JSDoc comments
readonlybooleanfalseGenerate readonly properties
excludestring[][]Files to exclude

🖥️ CLI Commands

init

Initialize configuration with interactive prompts.

npx typeweaver init

Options:

  • --force - Overwrite existing config

generate

Generate types once from your schemas.

npx typeweaver generate

Options:

  • --config <path> - Custom config file path
  • --output <path> - Override output path
  • --dry-run - Preview without writing
  • --verbose - Show detailed output

watch

Watch schemas and auto-generate types on changes.

npx typeweaver watch

Options:

  • --config <path> - Custom config file path
  • --output <path> - Override output path

verify

Verify types are in sync with schemas (great for CI/CD).

npx typeweaver verify

info

Show current configuration.

npx typeweaver info

clean

Remove all generated type files.

npx typeweaver clean

Options:

  • --dry-run - Preview files to be deleted

🎯 Use Cases

1. MERN Stack Development

backend/
  models/
    User.js
    Post.js
  typeweaver.config.json

frontend/
  types/  ← Auto-generated
    index.ts

2. Monorepo with Multiple Frontends

{
  "orm": "prisma",
  "schemaPath": "./backend/schema.prisma",
  "outputPath": [
    "../web-app/src/types",
    "../mobile-app/src/types",
    "../admin-dashboard/src/types"
  ]
}

3. API Development

Generate types for your TypeScript SDK:

api/
  schema.prisma
  typeweaver.config.json → outputs to sdk/types/
sdk/
  types/
    index.ts  ← Auto-generated

🔧 Advanced Usage

Custom Type Mapping

{
  "customTypeMap": {
    "ObjectId": "string",
    "Mixed": "Record<string, any>"
  }
}

Multiple Output Paths

{
  "outputPath": ["./frontend/types", "./mobile/types"]
}

Exclude Patterns

{
  "exclude": ["**/node_modules/**", "**/*.test.js", "**/deprecated/**"]
}

🆚 Comparison

SolutionZero MigrationReal-TimeNo Stack Lock-inSetup Time
typeweaver✅ (<500ms)<1 min
GraphQL Codegen❌ (Requires GraphQL)⚠️ (Slow)Weeks
tRPC❌ (Full rewrite)Days
Manual npm packages❌ (10+ min)Hours
Monorepo sharing⚠️ (Complex)⚠️ (Requires rebuild)Days

🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md.

Development Setup

# Clone repo
git clone https://github.com/yourusername/type-bridge.git
cd type-bridge

# Install dependencies
npm install

# Run tests
npm test

# Test CLI locally
node bin/typeweaver.js generate --help

📝 License

MIT © TypeWeaver Contributors

🙏 Acknowledgments

  • Inspired by the pain of manual type synchronization
  • Built for the full-stack TypeScript community
  • Thanks to all contributors and early adopters

📞 Support

🗺️ Roadmap

✅ v1.0.0 (Current - November 2025)

  • ✅ Prisma support
  • ✅ Mongoose support
  • ✅ Circular reference detection
  • ✅ Nested object support
  • ✅ Verification command
  • ✅ Better type mappings
  • ✅ Production ready!

v1.1.0 (Planned)

  • Custom type mappings configuration
  • Field transformations (removeFields, renameFields)
  • Better error messages with line numbers

v1.2.0 (Planned)

  • DTO generation (CreateDto, UpdateDto, ResponseDto)
  • TypeORM support
  • Sequelize support

v1.3.0+ (Future)

  • Zod schema generation
  • GraphQL schema generation
  • React Query hooks generation
  • tRPC router generation
  • VS Code extension

Made with ❤️ for full-stack TypeScript developers

Stop wasting time on type synchronization. Start using typeweaver today! 🚀

Keywords

typescript

FAQs

Package last updated on 23 Nov 2025

Did you know?

Socket

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.

Install

Related posts