TypeScript

Enforce type-safety in TypeScript projects through narrowing and strict mode guidance.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/ViewWay/openclaw-skills --skill typescript-viewway
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TypeScript
Source: https://github.com/ViewWay/openclaw-skills/tree/main/typescript
Command: npx skills add https://github.com/ViewWay/openclaw-skills --skill typescript-viewway

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript projects often struggle with unsafe types, unclear narrowing, and brittle generic patterns. It guides teams to write type-safe code with proper narrowing, robust inference, and strict mode best practices.

Core Features & Use Cases

  • Type narrowing and inference: ensures exhaustive checks and preserves literal types.
  • Discriminated unions and strict generics: enables safe composition of complex APIs.
  • Migration guidance and best practices: helps teams transition from JavaScript to TypeScript gradually.

Quick Start

Describe a TypeScript problem you'd like solved, and I'll generate type-safe patterns and code examples to apply immediately.

Frequently Asked Questions about TypeScript

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

FAQPage Schema
How do I enforce type-safety and eliminate unsafe any types in TypeScript?

To enforce type-safety, enable strict mode and use unknown as a safer default over any. This approach promotes explicit typing and helps identify unsafe patterns during static analysis, ensuring maintainable code.

What is the best way to implement type narrowing with discriminated unions in TypeScript?

Type narrowing with discriminated unions is best implemented by ensuring exhaustive checks and preserving literal types. This enables safe composition of complex APIs and prevents invalid state transitions at compile time.

How do I write robust generics for complex TypeScript APIs?

Writing robust generics requires applying strict inference patterns and type narrowing. This ensures that your generic APIs remain type-safe, maintain their literal types, and compose safely without runtime type conflicts.

Can I get migration guidance for transitioning a JavaScript project to strict TypeScript?

Yes, you can transition from JavaScript to TypeScript gradually using migration guidance and best practices. This involves applying strict mode and explicit typing incrementally to ensure type-safe, maintainable code.

Why does TypeScript type narrowing fail to preserve literal types in my generic functions?

Type narrowing fails to preserve literal types when strict inference patterns are not applied. To fix this, ensure exhaustive checks and use discriminated unions to maintain literal types safely throughout your generic APIs.