typescript

Refactor TypeScript codebases to use const-based unions and flat interfaces.

Updated Mar 15, 2026
One-click install
npx skills add https://github.com/sebasmzg/sebas.dot --skill typescript-sebasmzg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/sebasmzg/sebas.dot/tree/main/.config/opencode/skill/typescript
Command: npx skills add https://github.com/sebasmzg/sebas.dot --skill typescript-sebasmzg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript projects often have fragile or inconsistent type definitions, duplicated runtime values, inline nested types, and unsafe uses of any; this Skill provides concise patterns and best practices to make types reliable, refactorable, and aligned with runtime values for safer and more maintainable code.

Core Features & Use Cases

  • Single-source-of-truth runtime enums: prefer creating const objects and deriving union types to enable autocomplete, runtime validation, and easier refactors.
  • Flat interface design: extract nested inline object types into dedicated interfaces to improve clarity, reuse, and extendability across domains and APIs.
  • Strict typing guidance: avoid any, prefer unknown with type guards, use utility types, and import type annotations to keep public APIs explicit. Use cases include migrating legacy TypeScript code, enforcing repository-wide style during code review, and scaffolding new modules with robust type-safe patterns.

Quick Start

Refactor my TypeScript file to replace inline union strings with a const object extraction pattern, extract nested inline object types into named interfaces, and remove uses of any by introducing appropriate type guards and utility-type transformations.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I replace inline string unions with a const object extraction pattern in TypeScript?

To enforce strict TypeScript patterns, replace `any` with `unknown` and apply type guards for runtime validation. This approach ensures type safety by forcing explicit checks before accessing properties, keeping public APIs robust and predictable.

What is the best way to refactor nested inline object types into flat interfaces?

The best way to refactor nested inline object types into flat interfaces is to extract them into dedicated, named interfaces. This flat interface design improves code clarity, reusability, and extendability across domains and APIs during TypeScript migrations.

Can I use utility types and import type annotations for library development?

Yes, you can use utility types and `import type` annotations for library development. Applying these strict typing patterns keeps public APIs explicit, prevents runtime bundling of type-only dependencies, and ensures safer application code.

Why does my TypeScript codebase have fragile type definitions and duplicated runtime values?

TypeScript codebases develop fragile type definitions and duplicated runtime values when types and values are managed separately. Refactoring to use const-based unions and flat interfaces aligns types with runtime values for safer, more maintainable code.

When should I not use the `any` type in TypeScript code reviews?

You should never use the `any` type in TypeScript code reviews when enforcing strict typing patterns. Instead of `any`, prefer `unknown` combined with type guards and utility types to maintain type safety and prevent silent runtime errors.