AgentSkillsCN

typescript-patterns

运用路径别名、严格类型检查、类型守卫,以及验证模式等 TypeScript 规范。当需要处理 TypeScript 代码、导入模块、定义接口、编写类型定义,或当用户提及类型、接口、类型守卫、验证机制、Valibot、导入路径、类型安全,或类型断言时,可调用此技能。

SKILL.md
--- frontmatter
name: typescript-patterns
description: TypeScript patterns including path aliases, strict typing, type guards, and validation patterns. Use when working with TypeScript code, imports, interfaces, type definitions, or when user mentions types, interfaces, type guards, validation, Valibot, imports, path aliases, type safety, or type assertions.
license: Unlicense

TypeScript Patterns

TypeScript patterns and strict typing rules.

Quick Reference

  • Imports: See imports.md for path aliases (~/@, ~~/, #shared, #server)
  • Types: See types.md for interfaces and when to use interface vs type
  • Type Guards: See guards.md for type predicates and runtime type checking
  • Type Assertions: See type-assertions.md for avoiding as keyword
  • Validation: See validation.md for Valibot validation patterns

Strict Typing Rules

  • NO any types - always use proper types or unknown
  • Explicit return types on exported functions
  • Use unknown for uncertain types, then narrow with type guards
  • Import types separately: import type { ... } when only importing types