Instructions
Write TypeScript types and interfaces under srs/types for the Next.js app. Derive the types from
the domain model / API spec provided, keeping them modular and easy to consume across the app.
Workflow
- Model the domain — identify the entities, their fields, and the relationships between them from the spec. Decide what is required vs. optional, and what is a finite set (→ union/enum).
- Choose the shape —
interfacefor object shapes that may be extended/implemented;typefor unions, intersections, mapped/utility types, and primitives aliases. - Organize into files — one cohesive concern per file (e.g.
user.ts,order.ts,api/responses.ts), re-exported from anindex.tsbarrel so consumers import fromsrs/types. - Name precisely —
PascalCasefor types/interfaces, suffix request/response DTOs clearly (CreateUserRequest,UserResponse), avoid abbreviations. - Constrain, don't widen — prefer literal unions over
string,readonlyfor immutable data, and avoidany(useunknown+ narrowing when the shape is genuinely open).
Rules
- Make it modular.
- Separate the types and interfaces into multiple files if possible.
- Maximum of 50 lines of code per file.
Example
ts// srs/types/user.ts export type UserRole = "admin" | "member" | "guest"; export interface User { id: string; email: string; role: UserRole; createdAt: string; // ISO-8601 displayName?: string; } export interface CreateUserRequest { email: string; role?: UserRole; }
ts// srs/types/index.ts export * from "./user"; export * from "./order";
Quality bar
- No
any; optionality reflects the real contract (don't mark required fields optional). - Each file stays under 50 lines and covers one concern; shared primitives live in a common module.
- Types compile cleanly and are importable as
import type { User } from "@/srs/types".


