TypeScript coding standards and best practices for modern web development
Add this skill
npx mdskills install PatrickJS/cursor-typescriptComprehensive TypeScript guidelines with solid conventions but lacks actionable agent instructions
1---2description: TypeScript coding standards and best practices for modern web development3globs: **/*.ts, **/*.tsx, **/*.d.ts4---56# TypeScript Best Practices78## Type System9- Prefer interfaces over types for object definitions10- Use type for unions, intersections, and mapped types11- Avoid using `any`, prefer `unknown` for unknown types12- Use strict TypeScript configuration13- Leverage TypeScript's built-in utility types14- Use generics for reusable type patterns1516## Naming Conventions17- Use PascalCase for type names and interfaces18- Use camelCase for variables and functions19- Use UPPER_CASE for constants20- Use descriptive names with auxiliary verbs (e.g., isLoading, hasError)21- Prefix interfaces for React props with 'Props' (e.g., ButtonProps)2223## Code Organization24- Keep type definitions close to where they're used25- Export types and interfaces from dedicated type files when shared26- Use barrel exports (index.ts) for organizing exports27- Place shared types in a `types` directory28- Co-locate component props with their components2930## Functions31- Use explicit return types for public functions32- Use arrow functions for callbacks and methods33- Implement proper error handling with custom error types34- Use function overloads for complex type scenarios35- Prefer async/await over Promises3637## Best Practices38- Enable strict mode in tsconfig.json39- Use readonly for immutable properties40- Leverage discriminated unions for type safety41- Use type guards for runtime type checking42- Implement proper null checking43- Avoid type assertions unless necessary4445## Error Handling46- Create custom error types for domain-specific errors47- Use Result types for operations that can fail48- Implement proper error boundaries49- Use try-catch blocks with typed catch clauses50- Handle Promise rejections properly5152## Patterns53- Use the Builder pattern for complex object creation54- Implement the Repository pattern for data access55- Use the Factory pattern for object creation56- Leverage dependency injection57- Use the Module pattern for encapsulation
Full transparency — inspect the skill content before installing.