understand-type-widening

Installation
SKILL.md

Understand Type Widening

Overview

When TypeScript infers a type from a value, it often widens it.

A variable initialized with "x" could be intended to hold any string, or just the literal "x". TypeScript guesses using heuristics, and understanding these helps you write predictable code.

When to Use This Skill

  • Confused why a type is string instead of "specific-value"
  • const and let give different types for the same value
  • Array literals get unexpected element types
  • Object properties are wider than expected
  • Type errors about literals not being assignable

The Iron Rule

Related skills
Installs
9
GitHub Stars
2
First Seen
Feb 3, 2026