Frontend Typescript Standards

Standardized guidelines and patterns for Frontend Typescript Standards.

valec3 5fad650 1.3 KB Updated

File contents

Frontend Typescript Standards

When to use this skill

  • Setting up TypeScript in a new project
  • Establishing coding standards
  • Code reviews for TypeScript quality

Workflow

  • Enable strict mode in tsconfig.json
  • Use interfaces for object shapes
  • Prefer type for unions and intersections
  • Always type function parameters and returns
  • Avoid any, use unknown instead

Instructions

tsconfig.json

{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true
  }
}

Naming Conventions

  • Interfaces: PascalCase with I prefix optional
  • Types: PascalCase
  • Enums: PascalCase
  • Generics: Single capital letter or PascalCase

Type vs Interface

// Use interface for object shapes
interface User {
  id: string;
  name: string;
}

// Use type for unions, intersections
type Status = 'pending' | 'active' | 'inactive';
type Admin = User & { role: 'admin' };

Resources

  • Enable all strict flags
  • Type everything explicitly
  • Use utility types (Partial, Pick, Omit)

valec3/Agents.skills.md/tree/main/.agent/skills/frontend-typescript-standards commit 5fad650ee5

Frequently asked questions

npx skillmds add valec3/frontend-typescript-standards