typescript-type-safe-api-contracts
Installation
SKILL.md
TypeScript Type-Safe API Contracts
Core Principle: Explicit Return Types (Mandatory)
// BAD: Implicit return type
export function getUser(id: string) {
return db.user.findUnique({ where: { id } });
}
// GOOD: Explicit return type
export async function getUser(id: string): Promise<User | null> {
return db.user.findUnique({ where: { id } });
}
Interface vs Type
Use interface for object shapes: