typescript

Enforces strict TypeScript patterns for types, interfaces, generics, and type guards.

4|Updated May 13, 2026
One-click install
npx skills add https://github.com/RuixeWolf/modbus-simulator --skill typescript-ruixewolf
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/RuixeWolf/modbus-simulator/tree/main/.agents/skills/typescript
Command: npx skills add https://github.com/RuixeWolf/modbus-simulator --skill typescript-ruixewolf

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Inconsistent TypeScript codebases suffer from scattered union types, deeply nested inline interfaces, and unsafe any usage that erode type safety and make refactoring painful. This Skill enforces a single, strict set of TypeScript conventions so every type definition follows the same maintainable pattern. ## Core Features & Use Cases - Const Object Type Pattern: Derives union types from as const objects to create a single source of truth with runtime values and autocomplete. - Flat Interface Design: Requires one-level-deep interfaces with dedicated named interfaces for nested objects, plus extension via extends. - Type Safety Rules: Bans any in favor of unknown and generics, and standardizes type guards, utility types, and import type syntax. - Use Case: When writing a new API response model, apply the const-object pattern for status fields, extract nested payloads into dedicated interfaces, and add a type guard for runtime validation. ## Quick Start Write TypeScript types for a user model with a status field following the strict const-object and flat-interface patterns.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I create a union type from an object in TypeScript?▼

Define a const object with `as const`, then extract the union with `(typeof OBJ)[keyof typeof OBJ]`. This gives a single source of truth with runtime values, autocomplete, and easier refactoring compared to writing a direct string union.

What is the best way to type nested objects in TypeScript interfaces?▼

Keep interfaces flat at one level of depth by extracting nested objects into their own dedicated interfaces and referencing them. Avoid inline nested object types, which hurt readability and reuse.

When should I use unknown instead of any in TypeScript?▼

Use `unknown` for truly unknown inputs, such as parsed external data, because it forces type narrowing before use. Reserve generics for flexible reusable functions, and avoid `any` entirely since it disables type checking.

How do I write a type guard in TypeScript?▼

Write a function returning `value is Type` that checks the value is a non-null object and verifies required keys with the `in` operator. This lets TypeScript narrow `unknown` values safely at runtime boundaries.

Which TypeScript utility types are most commonly used?▼

Common utility types include Pick, Omit, Partial, Required, Readonly, Record, Extract, Exclude, NonNullable, ReturnType, and Parameters. They transform existing types without redefining fields manually.