Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问clear审计通过

typescript-advanced-patternsTypeScript 高级模式

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

679

周安装

28

GitHub Stars

88

下载量

222
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:typescript-advanced-patterns(TypeScript 高级模式)
来源仓库:https://github.com/blockmatic/basilic
仓库路径:skills/typescript-advanced-patterns
安装命令:
npx skills add https://github.com/blockmatic/basilic --skill typescript-advanced-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/blockmatic/basilic --skill typescript-advanced-patterns

简介

TypeScript v5+ 高级类型系统实战手册,包含条件类型与映射类型深度应用。

  • 提供 discriminated union、branded types 与 template literal 类型编程范例。
  • 强调 strict 模式必要性,禁用 any 类型以保证编译期安全保障。
  • 复杂领域模型建议配合 Zod 运行时校验,形成双重保障机制。
  • typescript-advanced-patterns 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Skill: typescript

Scope

  • Applies to: TypeScript v5+ advanced type system features, type-safe APIs, complex domain models, sophisticated type inference, compile-time guarantees
  • Does NOT cover: Basic TypeScript syntax, framework-specific patterns, runtime validation libraries (use Zod separately)

Assumptions

  • TypeScript v5+
  • Strict mode enabled ("strict": true in tsconfig.json)
  • Target: ES2020+ or higher

Principles

  • Use conditional types for type selection based on conditions
  • Use mapped types for systematic object type transformations
  • Use type guards (value is Type) for runtime checking with type narrowing
  • Use discriminated unions for type-safe state machines with exhaustiveness checking
  • Use branded types to prevent primitive mixing
  • Prefer unknown over any for type safety
  • Use type guards over type assertions (as Type)
  • Keep types composable and shallow (avoid deep nesting)
  • Mark immutable data structures as readonly

Constraints

MUST

  • Enable strict mode ("strict": true in tsconfig.json)
  • Use unknown instead of any for untyped values
  • Use type guards (value is Type) instead of type assertions when possible

SHOULD

  • Use type for unions/utilities, interface for object shapes
  • Keep types composable and shallow
  • Mark immutable data structures as readonly
  • Use branded types to prevent primitive mixing

AVOID

  • Using any (use unknown with type guards)
  • Type assertions without validation
  • Overusing generics (only when types truly vary)
  • Deep type nesting (slow compilation, hard to debug)

Interactions

  • Works with zod for runtime validation with type inference
  • Complements nextjs for type-safe API routes
  • Complements fastify for type-safe route schemas

Patterns

Mapped Types

Transform object types systematically:

type Partial<T> = { [P in keyof T]?: T[P] }
type Readonly<T> = { readonly [P in keyof T]: T[P] }
type Pick<T, K extends keyof T> = { [P in K]: T[P] }

Type Guards

Runtime type checking with type narrowing:

function isString(value: unknown): value is string {
  return typeof value === 'string'
}

function isSuccess(result: Result): result is Success {
  return result.status === 'success'
}

Branded Types

Create nominal types for type safety:

type UserId = string & { readonly __brand: 'UserId' }
type PostId = string & { readonly __brand: 'PostId' }

function createUserId(id: string): UserId {
  return id as UserId
}

Discriminated Unions

Type-safe state machines with exhaustiveness checking:

type LoadingState =
  | { status: 'idle' }
  | { status: 'loading' }
  | { status: 'success'; data: string[] }
  | { status: 'error'; error: Error }

References

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenCode

31.4%
按下载量换算70

Claude Code

22.35%
按下载量换算50

windsurf

17.37%
按下载量换算39

trae

12.11%
按下载量换算27

Cursor

8.53%
按下载量换算19

weavefox

3.22%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills