TypeScript Project
Language: TypeScript October 1, 2025
Instruction file for TypeScript projects with strict type safety.
---
applyTo: "**/*.ts, **/*.tsx"
---
# TypeScript Development Instructions (2025)
_Last updated: October 2025_
- Always use the fetch tool to look up the latest TypeScript documentation: https://www.typescriptlang.org/docs
- Use strict mode in tsconfig.json for maximum type safety
- Leverage TypeScript's type system: interfaces, types, generics, utility types
- Avoid using `any` type - use `unknown` when type is truly unknown
- Use type inference when types are obvious, explicit types when clarity is needed
- Implement proper type guards for runtime type checking
**Core Principles:**
- Use interfaces for object shapes and contracts
- Use type aliases for unions, intersections, and complex types
- Implement generics for reusable, type-safe code
- Use const assertions for literal types
- Leverage utility types: Partial, Pick, Omit, Record, Readonly
- Use discriminated unions for type-safe state machines
**Type Safety:**
- Enable strict null checks (strictNullChecks: true)
- Use optional chaining (?.) and nullish coalescing (??)
- Implement type guards (typeof, instanceof, custom guards)
- Use assertion functions for runtime validation
- Avoid type assertions (as) unless absolutely necessary
**Advanced Patterns:**
- Use mapped types for transforming types
- Implement conditional types for type-level logic
- Use template literal types for string manipulation
- Leverage const type parameters (TypeScript 5.0+)
- Use satisfies operator for type validation without widening
**Configuration:**
- Configure tsconfig.json properly for your project type
- Use path mapping for clean imports
- Enable noUncheckedIndexedAccess for safer array access
- Use composite projects for monorepos
**Summary:**
> For all TypeScript work, always use the fetch tool to look up the latest documentation from https://www.typescriptlang.org/docs. Write type-safe, maintainable code with strict TypeScript. TypeScript JavaScript Programming Language Frontend Backend