TYPES-any-vs-unknown
CommunityEliminate `any` type abuse, embrace `unknown` for safety.
Software Engineering#code quality#type safety#typescript#refactoring#type guards#unknown type#external data#any type
Authordjankies
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Overusing the any type disables TypeScript's type checking, allowing runtime errors that should have been caught at compile time. This Skill teaches how to eliminate any type abuse by using unknown with proper type guards.
Core Features & Use Cases
anyvs.unknown: Understand the critical distinction:anydisables checks,unknownrequires narrowing.- Decision Flow: Guides on when to use specific types,
unknown, or (rarely)anyfor truly dynamic data. - Type Guard Implementation: Learn to implement type guards (
typeof,instanceof,in, custom predicates) to safely narrowunknownvalues. - Safe External Data Handling: Apply
unknownand validation to API responses, JSON parsing, and user input to prevent runtime crashes. - Use Case: Refactor
src/data/api.tsto replaceanyreturn types from API calls withunknown, then add type guards to safely process the data, ensuring type safety and preventing runtime errors.
Quick Start
Replace any with unknown in the processExternalData function in src/utils/parser.ts, then add a type guard to safely access its properties.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: TYPES-any-vs-unknown Download link: https://github.com/djankies/claude-configs/archive/main.zip#types-any-vs-unknown Please download this .zip file, extract it, and install it in the .claude/skills/ directory.