Fix TypeScript Errors Skill
Systematic approach to resolving TypeScript type errors using Bun and standard TS practices.
Workflow
- •
Initial Audit: Run the type check to get the full error list.
powershellbun run typecheck
- •
Pattern Identification: Analyze the output for common issues:
- •Missing type annotations in exported functions.
- •Type mismatches in prop interfaces.
- •Implicit
anyusages in complex logic. - •Missing module or type definition imports.
- •
Resolution Strategy:
- •Explicit Annotations: Add types to parameters and return signatures.
- •Type Guarding: Use
typeofor custom guards to narrowunknown. - •Refactoring: Replace
anywith specific types or interfaces. - •Dependency Fixes: Install missing
@types/*if external packages are involved.
- •
Verification: Re-run the check and ensure counts decrease.
powershellbun run typecheck
Best Practices
- •Prefer
unknownoveranyfor uncertain external data. - •Co-locate local types with their primary usage files.
- •Use explicit return types for all public API functions.