typescript

Enforce type-safe TypeScript patterns for imports, error handling, and type selection.

1|Updated May 9, 2026
One-click install
npx skills add https://github.com/duwenji/generative-ai-oss-tutorials --skill typescript-duwenji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/duwenji/generative-ai-oss-tutorials/tree/main/sandbox/lobe-chat/.agents/skills/typescript
Command: npx skills add https://github.com/duwenji/generative-ai-oss-tutorials --skill typescript-duwenji

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reduces bugs and review churn by enforcing consistent, type-safe TypeScript patterns that prevent silent failures and risky type usage.

Core Features & Use Cases

  • Stronger type safety: Prefer Record<PropertyKey, unknown> over any/object, choose interface vs type appropriately, and use as const satisfies to validate literals.
  • Correct error handling: Avoid silent fallbacks by requiring logging in catch paths and discouraging .catch(() => fallback).
  • Maintainable architecture: Prefer declare module over namespace, and design extensible types with local augmentation near the feature/plugin that consumes/produces metadata.
  • Team-consistent style: Enforce deterministic imports (separate type imports, alphabetized specifiers) and named exports over export default.

Quick Start

Ask to “review this change for TypeScript type quality, import correctness, and unsafe async/error-handling patterns according to the typescript skill rules.”

Frequently Asked Questions about typescript

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

FAQPage Schema
When should I use interface vs type in TypeScript for safer code?

Choosing between interface vs type in TypeScript depends on extensibility; use interface for object shapes open to declaration merging, and type for unions or primitives. This ensures safer, more maintainable code by preventing unintended shape modifications.

How do I fix unsafe TypeScript error handling with silent catch fallbacks?

To fix unsafe TypeScript error handling, avoid silent `.catch(() => fallback)` patterns and require error logging in catch paths. This prevents silent failures by ensuring that exceptions are explicitly logged before applying fallback values, improving runtime debugging and application stability.

What is the correct way to separate type imports in TypeScript?

The correct way to separate type imports in TypeScript is using `import type` syntax alongside alphabetized specifiers. This enforces deterministic imports by isolating type-only dependencies from runtime values, reducing bundle size and preventing circular dependency issues during compilation.

How do I validate literal types in TypeScript without losing narrowness?

To validate literal types in TypeScript without losing narrowness, use the `as const satisfies` pattern. This approach checks that a literal matches a broader expected type while preserving the narrow literal values, enforcing strict type safety and preventing invalid literal assignments.

Why does TypeScript prefer Promise.all over individual await in async patterns?

TypeScript prefers `Promise.all` over individual `await` in async patterns to enforce parallel execution. This prevents waterfall network delays and ensures deterministic async behavior by resolving independent promises concurrently, resulting in faster and more predictable application performance.

What is the best way to replace any with Record<PropertyKey, unknown> in TypeScript?

The best way to replace `any` with `Record<PropertyKey, unknown>` in TypeScript is by enforcing explicit type narrowing. This approach maintains type safety by forcing downstream type checks before property access, eliminating risky implicit assumptions and preventing runtime type errors.