Skip to main content
AIPromptIndex
GitHub Copilot Coding advanced

Copilot Interface Generator

Added Apr 2, 2026

You are a TypeScript architect specializing in type system design. Generate comprehensive TypeScript interfaces and types for a [DOMAIN] module in a [PROJECT_TYPE] project. The module handles [FUNCTIONALITY] and interacts with [EXTERNAL_SYSTEMS]. Create the following: entity interfaces for all domain objects with proper typing (no 'any' types), request and response DTOs for API endpoints, union types and discriminated unions for state management, utility types using TypeScript generics (Partial, Pick, Omit, Record patterns) for common transformations, enum definitions for fixed value sets, type guards and assertion functions for runtime type checking, Zod or io-ts validation schemas that mirror the interfaces for runtime validation, and a barrel export file organizing all types logically. Follow these conventions: use PascalCase for types and interfaces, prefix interfaces with 'I' only if the project convention requires it, make fields readonly where mutation is not intended, use branded types for IDs to prevent mixing different entity IDs, and document every interface with JSDoc including field descriptions and usage examples.
0
Share
Try in GitHub Copilot

About This Prompt

This prompt generates a complete TypeScript type system for any domain, producing interfaces, DTOs, union types, utility types, type guards, and runtime validators in one cohesive output. A well-designed type system catches bugs at compile time, serves as living documentation, and makes refactoring safer. This prompt applies TypeScript best practices like branded types for IDs, discriminated unions for state, and Zod schemas for runtime validation. It is especially valuable when starting a new module, migrating from JavaScript to TypeScript, or cleaning up a codebase that overuses 'any' types.

Variables to Customize

[DOMAIN]

The business domain for the types

Example: e-commerce orders

[PROJECT_TYPE]

Type of application

Example: Next.js full-stack application

[FUNCTIONALITY]

What the module manages

Example: order creation, status tracking, payment processing, and fulfillment

[EXTERNAL_SYSTEMS]

External APIs and services involved

Example: Stripe payments API, warehouse fulfillment API, and email notification service

Tips for Best Results

  • Use branded types for entity IDs to catch bugs where you accidentally pass a userId where an orderId is expected
  • Generate Zod schemas alongside interfaces to get both compile-time and runtime type safety
  • Export types from a central barrel file so imports stay clean throughout the project

Example Output

// types/order.ts

/** Branded type to prevent mixing Order IDs with other entity IDs */
type OrderId = string & { readonly __brand: 'OrderId' };
type UserId = string & { readonly __brand: 'UserId' };

/** All possible states an order can be in */
type OrderStatus = 'pending' | 'confirmed' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';

/** Core order entity as stored in the database */
interface Order {
  readonly id: OrderId;
  readonly userId: UserId;
  readonly items: readonly OrderItem[];
  readonly status: OrderStatus;
  readonly total: number;
  readonly currency: string;
  readonly createdAt: Date;
  readonly updatedAt: Date;
}

/** Request DTO for creating a new order */
interface CreateOrderRequest {
  items: Array<{ productId: string; quantity: number }>;
  shippingAddress: Address;
  paymentMethodId: string;
}

// Zod validation schema
const createOrderSchema = z.object({
  items: z.array(z.object({ productId: z.string().uuid(), quantity: z.number().int().positive() })).min(1),
  ...
typescript type-system interfaces api-design software-architecture

Get the Best AI Prompts Weekly

Curated prompts, tips, and guides delivered to your inbox every week. Free.