AgentSkillsCN

typescript

当用户提出“优化 TypeScript 性能”、“加快 tsc 编译速度”、“配置 tsconfig.json”、“修复类型错误”、“改进异步模式”,或遇到 TS 错误(TS2322、TS2339、“无法赋值给…”)时,可使用此技能。此外,当您处理 .ts、.tsx、.d.ts 文件,涉及类型定义、模块组织,或内存管理时,此技能也会自动触发。但请注意,此技能不涵盖 TypeScript 基础知识、特定框架下的设计模式,也不适用于测试相关的内容。

SKILL.md
--- frontmatter
name: typescript
description: This skill should be used when the user asks to "optimize TypeScript performance", "speed up tsc compilation", "configure tsconfig.json", "fix type errors", "improve async patterns", or encounters TS errors (TS2322, TS2339, "is not assignable to"). Also triggers on .ts, .tsx, .d.ts file work involving type definitions, module organization, or memory management. Does NOT cover TypeScript basics, framework-specific patterns, or testing.

TypeScript Best Practices

Comprehensive performance optimization guide for TypeScript applications. Contains 42 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Configuring tsconfig.json for a new or existing project
  • Writing complex type definitions or generics
  • Optimizing async/await patterns and data fetching
  • Organizing modules and managing imports
  • Reviewing code for compilation or runtime performance

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Type System PerformanceCRITICALtype-
2Compiler ConfigurationCRITICALtscfg-
3Async PatternsHIGHasync-
4Module OrganizationHIGHmodule-
5Type Safety PatternsMEDIUM-HIGHsafety-
6Memory ManagementMEDIUMmem-
7Runtime OptimizationLOW-MEDIUMruntime-
8Advanced PatternsLOWadvanced-

Table of Contents

  1. Type System PerformanceCRITICAL
  2. Compiler ConfigurationCRITICAL
  3. Async PatternsHIGH
  4. Module OrganizationHIGH
  5. Type Safety PatternsMEDIUM-HIGH
  6. Memory ManagementMEDIUM
  7. Runtime OptimizationLOW-MEDIUM
  8. Advanced PatternsLOW

References

  1. https://github.com/microsoft/TypeScript/wiki/Performance
  2. https://www.typescriptlang.org/docs/handbook/
  3. https://v8.dev/blog
  4. https://nodejs.org/en/learn/diagnostics/memory