TYPES-any-vs-unknown

Community

Eliminate `any` type abuse, embrace `unknown` for safety.

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

  • any vs. unknown: Understand the critical distinction: any disables checks, unknown requires narrowing.
  • Decision Flow: Guides on when to use specific types, unknown, or (rarely) any for truly dynamic data.
  • Type Guard Implementation: Learn to implement type guards (typeof, instanceof, in, custom predicates) to safely narrow unknown values.
  • Safe External Data Handling: Apply unknown and validation to API responses, JSON parsing, and user input to prevent runtime crashes.
  • Use Case: Refactor src/data/api.ts to replace any return types from API calls with unknown, 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 required

Components

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.
View Source Repository