首页/AI 代码生成与质效/typescript-magician
T

typescript-magician

by @mcollinav
4.3(47)

精通TypeScript,擅长设计复杂的泛型类型,并将`any`类型重构为严格类型,提升代码的健壮性和可维护性。

typescripttype-safetyadvanced-typescriptfrontend-developmentbackend-developmentGitHub
安装方式
npx skills add mcollina/skills --skill typescript-magician
compare_arrows

Before / After 效果对比

1
使用前

在大型TypeScript项目中,类型定义混乱或滥用any类型,导致代码难以维护。类型安全保障不足,运行时错误频发,影响开发效率和项目质量。

使用后

运用此技能,能够设计复杂泛型,重构any类型为严格替代方案。显著提升代码的类型安全和可维护性,减少运行时错误,加速开发进程。

SKILL.md

When to use

Use this skill for:

  • TypeScript errors and type challenges
  • Eliminating any types from codebases
  • Complex generics and type inference issues
  • When strict typing is needed

Instructions

When invoked:

  1. Run tsc --noEmit to capture the full error output before making changes
  2. Identify the root cause of type issues (unsound inference, missing constraints, implicit any, etc.)
  3. Craft precise, type-safe solutions using advanced TypeScript features
  4. Eliminate all any types with proper typing — validate each replacement still satisfies call sites
  5. Confirm the fix compiles cleanly with a second tsc --noEmit pass

Capabilities include:

  • Advanced generics and conditional types
  • Template literal types and mapped types
  • Utility types and type manipulation
  • Brand types and nominal typing
  • Complex inference patterns
  • Variance and distribution rules
  • Module augmentation and declaration merging

For every TypeScript challenge:

  • Explain the type theory behind the problem
  • Provide multiple solution approaches when applicable
  • Show before/after type representations
  • Include comprehensive type tests
  • Ensure full IntelliSense support

Quick Examples

Eliminating any with generics

Before

function getProperty(obj: any, key: string): any {
  return obj[key];
}

After

function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
  return obj[key];
}
// getProperty({ name: "Alice" }, "name") → inferred as string ✓

Narrowing an unknown API response

Before

async function fetchUser(): Promise<any> {
  const res = await fetch("/api/user");
  return res.json();
}

After

interface User { id: number; name: string }

function isUser(value: unknown): value is User {
  return (
    typeof value === "object" &&
    value !== null &&
    "id" in value &&
    "name" in value
  );
}

async function fetchUser(): Promise<User> {
  const res = await fetch("/api/user");
  const data: unknown = await res.json();
  if (!isUser(data)) throw new Error("Invalid user shape");
  return data;
}

Reference

Read individual rule files for detailed explanations and code examples:

Core Patterns

Advanced Generics

Type-Level Programming

Type Safety Patterns

Debugging

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量1.4K
评分4.3 / 5.0
版本
更新日期2026年5月22日
对比案例1 组

用户评分

4.3(47)
5
17%
4
49%
3
30%
2
4%
1
0%

为此 Skill 评分

0.0

兼容平台

🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI

时间线

创建2026年3月16日
最后更新2026年5月22日