typescript-strict

korallis 的头像作者 korallis

26. 编写严格的TypeScript代码,启用严格模式,全面的类型定义,适当的错误处理,消除任何类型。用于启用TypeScript严格模式、为现有JavaScript添加类型、修复类型错误、创建类型定义、使用实用工具类型、实现类型保护、避免任何类型、创建泛型类型或确保整个代码库的完整类型安全时使用。

📖 中文导读:26. 编写严格的TypeScript代码,启用严格模式,全面的类型定义,适当的错误处理,消除任何类型。用于启用TypeScript严格模式、为现有JavaScript添加类型、修复类型错误、创建类型定义、使用实用工具类型、实现类型保护、避免任何类型、创建泛型类型或确保整个代码库的完整类型安全时使用。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: typescript-strict description: Write type-safe TypeScript code with strict mode enabled, comprehensive type definitions, proper error handling, and elimination of any types. Use when enabling TypeScript strict mode, adding types to existing JavaScript, fixing type errors, creating type definitions, using utility types, implementing type guards, avoiding any types, creating generic types, or ensuring complete type safety across the codebase.

TypeScript Strict - Type Safety Best Practices

When to use this skill

  • Enabling TypeScript strict mode in projects
  • Adding types to existing JavaScript codebases
  • Fixing TypeScript type errors systematically
  • Creating comprehensive type definitions
  • Using TypeScript utility types (Partial, Pick, Omit)
  • Implementing type guards and assertions
  • Eliminating any types from codebase
  • Creating generic, reusable typed functions
  • Ensuring null/undefined safety
  • Typing complex data structures
  • Creating discriminated unions
  • Implementing strict function signatures

When to use this skill

  • Ensuring type safety, preventing runtime errors.
  • When working on related tasks or features
  • During development that requires this expertise

Use when: Ensuring type safety, preventing runtime errors.

Config

```json { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "noImplicitReturns": true } } ```

Resources