typescript-advanced-patterns by nickcrew/claude-ctx-plugin
npx skills add https://github.com/nickcrew/claude-ctx-plugin --skill typescript-advanced-patterns关于如何利用 TypeScript 高级类型系统特性构建健壮、类型安全的应用程序的专家指南,涵盖复杂的类型推断、编译时保证以及可维护的领域模型。
TypeScript 的类型系统通过以下方式实现编译时安全:
value is Type)按需加载详细参考:
| 主题 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 参考文件 |
|---|
| 条件类型 | skills/typescript-advanced-patterns/references/conditional-types.md |
| 映射类型 | skills/typescript-advanced-patterns/references/mapped-types.md |
| 模板字面量类型 | skills/typescript-advanced-patterns/references/template-literal-types.md |
| 类型守卫 | skills/typescript-advanced-patterns/references/type-guards.md |
| 可辨识联合 | skills/typescript-advanced-patterns/references/discriminated-unions.md |
| 标记类型 | skills/typescript-advanced-patterns/references/branded-types.md |
| 构建器模式 | skills/typescript-advanced-patterns/references/builder-pattern.md |
| 高级泛型 | skills/typescript-advanced-patterns/references/advanced-generics.md |
| 工具类型 | skills/typescript-advanced-patterns/references/utility-types.md |
| 类型推断 | skills/typescript-advanced-patterns/references/type-inference.md |
| 装饰器 | skills/typescript-advanced-patterns/references/decorators.md |
| 性能最佳实践 | skills/typescript-advanced-patterns/references/performance-best-practices.md |
| 常见陷阱 | skills/typescript-advanced-patterns/references/common-pitfalls.md |
| 测试类型 | skills/typescript-advanced-patterns/references/testing-types.md |
tsconfig.json 中设置 "strict": true)使用 any 而非 unknown:失去所有类型安全
unknown 和类型守卫未经验证的类型断言:不安全的运行时行为
value is Type)而非 as Type过度使用泛型:不必要的复杂性
深层类型嵌套:编译缓慢,难以调试
忘记 readonly:意外的突变
readonly未启用严格模式:遗漏空值检查和类型错误
tsconfig.json 中使用 "strict": true错误地混合使用 type 和 interface:语义混淆
type 处理联合/工具类型,使用 interface 处理对象形状type UserId = string & { readonly __brand: 'UserId' };
function createUserId(id: string): UserId { return id as UserId; }
type State =
| { status: 'loading' }
| { status: 'success'; data: string }
| { status: 'error'; error: Error };
type Readonly<T> = { readonly [P in keyof T]: T[P] };
type Partial<T> = { [P in keyof T]?: T[P] };
function isString(value: unknown): value is string {
return typeof value === 'string';
}
每周安装次数
72
仓库
GitHub 星标数
13
首次出现
2026年1月21日
安全审计
安装于
opencode64
gemini-cli56
codex54
github-copilot54
claude-code47
cursor46
Expert guidance for leveraging TypeScript's advanced type system features to build robust, type-safe applications with sophisticated type inference, compile-time guarantees, and maintainable domain models.
TypeScript's type system enables compile-time safety through:
value is Type)Load detailed references on-demand:
| Topic | Reference File |
|---|---|
| Conditional Types | skills/typescript-advanced-patterns/references/conditional-types.md |
| Mapped Types | skills/typescript-advanced-patterns/references/mapped-types.md |
| Template Literal Types | skills/typescript-advanced-patterns/references/template-literal-types.md |
| Type Guards | skills/typescript-advanced-patterns/references/type-guards.md |
| Discriminated Unions | skills/typescript-advanced-patterns/references/discriminated-unions.md |
tsconfig.json with "strict": true)Usingany instead of unknown: Loses all type safety
unknown and type guards insteadType assertions without validation : Unsafe runtime behavior
value is Type) over as TypeOverusing generics : Unnecessary complexity
Deep type nesting : Slow compilation, hard to debug
Forgettingreadonly: Accidental mutations
type UserId = string & { readonly __brand: 'UserId' };
function createUserId(id: string): UserId { return id as UserId; }
type State =
| { status: 'loading' }
| { status: 'success'; data: string }
| { status: 'error'; error: Error };
type Readonly<T> = { readonly [P in keyof T]: T[P] };
type Partial<T> = { [P in keyof T]?: T[P] };
function isString(value: unknown): value is string {
return typeof value === 'string';
}
Weekly Installs
72
Repository
GitHub Stars
13
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode64
gemini-cli56
codex54
github-copilot54
claude-code47
cursor46
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
120,000 周安装
| Branded Types | skills/typescript-advanced-patterns/references/branded-types.md |
| Builder Pattern | skills/typescript-advanced-patterns/references/builder-pattern.md |
| Advanced Generics | skills/typescript-advanced-patterns/references/advanced-generics.md |
| Utility Types | skills/typescript-advanced-patterns/references/utility-types.md |
| Type Inference | skills/typescript-advanced-patterns/references/type-inference.md |
| Decorators | skills/typescript-advanced-patterns/references/decorators.md |
| Performance Best Practices | skills/typescript-advanced-patterns/references/performance-best-practices.md |
| Common Pitfalls | skills/typescript-advanced-patterns/references/common-pitfalls.md |
| Testing Types | skills/typescript-advanced-patterns/references/testing-types.md |
readonlyNot enabling strict mode : Missing null checks and type errors
"strict": true in tsconfig.jsonMixing type and interface incorrectly : Confusing semantics
type for unions/utilities, interface for object shapes