avoid-wrapper-types

Convert TypeScript wrapper types to lowercase primitive types.

Updated Jul 17, 2017
One-click install
npx skills add https://github.com/luyi985/lyi-bash --skill avoid-wrapper-types
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: avoid-wrapper-types
Source: https://github.com/luyi985/lyi-bash/tree/main/ai/skills/avoid-wrapper-types
Command: npx skills add https://github.com/luyi985/lyi-bash --skill avoid-wrapper-types

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps prevent the misuse of object wrapper types in TypeScript by promoting lowercase primitives and explaining auto-boxing and common pitfalls.

Core Features & Use Cases

  • Enforce primitive types: string, number, boolean, symbol, bigint.
  • Explain why wrappers like String, Number, Boolean cause issues in type systems and at runtime.
  • Practical guidance for refactoring and static analysis to avoid wrapper usage in codebases.

Quick Start

Replace wrapper types with primitive types in your TypeScript codebase.

Frequently Asked Questions about avoid-wrapper-types

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do wrapper types like String and Number cause type-safety issues in TypeScript?

Wrapper types like String and Number cause type-safety issues in TypeScript because they are objects, not primitives, leading to unpredictable identity checks and runtime behavior due to auto-boxing. Using lowercase primitives enforces strict type consistency.

What is the difference between primitive types and wrapper types in TypeScript?

The difference between primitive types and wrapper types in TypeScript is that primitives (string, number, boolean) are immutable values, while wrappers (String, Number, Boolean) are objects. Primitives avoid auto-boxing pitfalls and ensure reliable type checking.

How do I convert wrapper types to primitive types in a TypeScript codebase?

To convert wrapper types to primitive types in a TypeScript codebase, replace uppercase wrappers like String, Number, and Boolean with their lowercase equivalents. This refactoring enforces type-safety and prevents runtime identity issues.

When should I avoid using object wrapper types in JavaScript and TypeScript?

You should avoid using object wrapper types in JavaScript and TypeScript whenever you need primitive values. Wrappers cause strict equality checks to fail and introduce unnecessary object overhead, making lowercase primitives the safer choice.

Does TypeScript auto-boxing affect equality checks for primitive types?

TypeScript auto-boxing temporarily wraps primitive types for method calls but does not affect equality checks for the primitives themselves. However, explicitly using wrapper types breaks identity comparisons because it creates distinct object instances.