AgentSkillsCN

typescript-strictness-enforcer

严格执行 TypeScript 严格类型检查:杜绝 any 类型,妥善处理空值,启用严格的类型选项。适用于新建文件、修改类型定义,或在使用 any 类型时使用。

SKILL.md
--- frontmatter
name: typescript-strictness-enforcer
description: Enforces TypeScript strictness: no any, proper null handling, strict options. Use when creating new files, modifying types, or using 'any'.

TypeScript Strictness Enforcer

When to Trigger

  • Creating new files
  • Modifying types
  • Using 'any'

What to Do

  1. Remove any: Replace with proper types or unknown and narrow.
  2. Null/undefined: Use optional chaining, nullish coalescing, or explicit return type (e.g. string | null).
  3. tsconfig: Recommend strict, noUncheckedIndexedAccess, noImplicitAny, strictNullChecks, noUnusedLocals, noUnusedParameters where appropriate.
  4. Interfaces: Define for function params and return types; use Prisma types or shared types from lib/types.

Suggest fixes with code; don’t weaken types to satisfy checks. Prefer type-safe patterns (discriminated unions, type guards).