[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BV07BYM1DSC28NJZ4N56S2":3,"skill-same:01M7BV07BYM1DSC28NJZ4N56S2":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BV07BYM1DSC28NJZ4N56S2","typescript-advanced-types",null,"Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Plugin-插件协议\u002FYYC3-Plugin-插件协议-external_plugins\u002Fjavascript-typescript\u002Fskills\u002Ftypescript-advanced-types\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: typescript-advanced-types\ndescription: Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.\n---\n\n# TypeScript Advanced Types\n\nComprehensive guidance for mastering TypeScript's advanced type system including generics, conditional types, mapped types, template literal types, and utility types for building robust, type-safe applications.\n\n## When to Use This Skill\n\n- Building type-safe libraries or frameworks\n- Creating reusable generic components\n- Implementing complex type inference logic\n- Designing type-safe API clients\n- Building form validation systems\n- Creating strongly-typed configuration objects\n- Implementing type-safe state management\n- Migrating JavaScript codebases to TypeScript\n\n## Core Concepts\n\n### 1. Generics\n\n**Purpose:** Create reusable, type-flexible components while maintaining type safety.\n\n**Basic Generic Function:**\n```typescript\nfunction identity\u003CT>(value: T): T {\n  return value;\n}\n\nconst num = identity\u003Cnumber>(42);        \u002F\u002F Type: number\nconst str = identity\u003Cstring>(\"hello\");    \u002F\u002F Type: string\nconst auto = identity(true);              \u002F\u002F Type inferred: boolean\n```\n\n**Generic Constraints:**\n```typescript\ninterface HasLength {\n  length: number;\n}\n\nfunction logLength\u003CT extends HasLength>(item: T): T {\n  console.log(item.length);\n  return item;\n}\n\nlogLength(\"hello\");           \u002F\u002F OK: string has length\nlogLength([1, 2, 3]);         \u002F\u002F OK: array has length\nlogLength({ length: 10 });    \u002F\u002F OK: object has length\n\u002F\u002F logLength(42);             \u002F\u002F Error: number has no length\n```\n\n**Multiple Type Parameters:**\n```typescript\nfunction merge\u003CT, U>(obj1: T, obj2: U): T & U {\n  return { ...obj1, ...obj2 };\n}\n\nconst merged = merge(\n  { name: \"John\" },\n  { age: 30 }\n);\n\u002F\u002F Type: { name: string } & { age: number }\n```\n\n### 2. Conditional Types\n\n**Purpose:** Create types that depend on conditions, enabling sophisticated type logic.\n\n**Basic Conditional Type:**\n```typescript\ntype IsString\u003CT> = T extends string ? true : false;\n\ntype A = IsString\u003Cstring>;    \u002F\u002F true\ntype B = IsString\u003Cnumber>;    \u002F\u002F false\n```\n\n**Extracting Return Types:**\n```typescript\ntype ReturnType\u003CT> = T extends (...args: any[]) => infer R ? R : never;\n\nfunction getUser() {\n  return { id: 1, name: \"John\" };\n}\n\ntype User = ReturnType\u003Ctypeof getUser>;\n\u002F\u002F Type: { id: number; name: string; }\n```\n\n**Distributive Conditional Types:**\n```typescript\ntype ToArray\u003CT> = T extends any ? T[] : never;\n\ntype StrOrNumArray = ToArray\u003Cstring | number>;\n\u002F\u002F Type: string[] | number[]\n```\n\n**Nested Conditions:**\n```typescript\ntype TypeName\u003CT> =\n  T extends string ? \"string\" :\n  T extends number ? \"number\" :\n  T extends boolean ? \"boolean\" :\n  T extends undefined ? \"undefined\" :\n  T extends Function ? \"function\" :\n  \"object\";\n\ntype T1 = TypeName\u003Cstring>;     \u002F\u002F \"string\"\ntype T2 = TypeName\u003C() => void>; \u002F\u002F \"function\"\n```\n\n### 3. Mapped Types\n\n**Purpose:** Transform existing types by iterating over their properties.\n\n**Basic Mapped Type:**\n```typescript\ntype Readonly\u003CT> = {\n  readonly [P in keyof T]: T[P];\n};\n\ninterface User {\n  id: number;\n  name: string;\n}\n\ntype ReadonlyUser = Readonly\u003CUser>;\n\u002F\u002F Type: { readonly id: number; readonly name: string; }\n```\n\n**Optional Properties:**\n```typescript\ntype Partial\u003CT> = {\n  [P in keyof T]?: T[P];\n};\n\ntype PartialUser = Partial\u003CUser>;\n\u002F\u002F Type: { id?: number; name?: string; }\n```\n\n**Key Remapping:**\n```typescript\ntype Getters\u003CT> = {\n  [K in keyof T as `get${Capitalize\u003Cstring & K>}`]: () => T[K]\n};\n\ninterface Person {\n  name: string;\n  age: number;\n}\n\ntype PersonGetters = Getters\u003CPerson>;\n\u002F\u002F Type: { getName: () => string; getAge: () => number; }\n```\n\n**Filtering Properties:**\n```typescript\ntype PickByType\u003CT, U> = {\n  [K in keyof T as T[K] extends U ? K : never]: T[K]\n};\n\ninterface Mixed {\n  id: number;\n  name: string;\n  age: number;\n  active: boolean;\n}\n\ntype OnlyNumbers = PickByType\u003CMixed, number>;\n\u002F\u002F Type: { id: number; age: number; }\n```\n\n### 4. Template Literal Types\n\n**Purpose:** Create string-based types with pattern matching and transformation.\n\n**Basic Template Literal:**\n```typescript\ntype EventName = \"click\" | \"focus\" | \"blur\";\ntype EventHandler = `on${Capitalize\u003CEventName>}`;\n\u002F\u002F Type: \"onClick\" | \"onFocus\" | \"onBlur\"\n```\n\n**String Manipulation:**\n```typescript\ntype UppercaseGreeting = Uppercase\u003C\"hello\">;  \u002F\u002F \"HELLO\"\ntype LowercaseGreeting = Lowercase\u003C\"HELLO\">;  \u002F\u002F \"hello\"\ntype CapitalizedName = Capitalize\u003C\"john\">;    \u002F\u002F \"John\"\ntype UncapitalizedName = Uncapitalize\u003C\"John\">; \u002F\u002F \"john\"\n```\n\n**Path Building:**\n```typescript\ntype Path\u003CT> = T extends object\n  ? { [K in keyof T]: K extends string\n      ? `${K}` | `${K}.${Path\u003CT[K]>}`\n      : never\n    }[keyof T]\n  : never;\n\ninterface Config {\n  server: {\n    host: string;\n    port: number;\n  };\n  database: {\n    url: string;\n  };\n}\n\ntype ConfigPath = Path\u003CConfig>;\n\u002F\u002F Type: \"server\" | \"database\" | \"server.host\" | \"server.port\" | \"database.url\"\n```\n\n### 5. Utility Types\n\n**Built-in Utility Types:**\n\n```typescript\n\u002F\u002F Partial\u003CT> - Make all properties optional\ntype PartialUser = Partial\u003CUser>;\n\n\u002F\u002F Required\u003CT> - Make all properties required\ntype RequiredUser = Required\u003CPartialUser>;\n\n\u002F\u002F Readonly\u003CT> - Make all properties readonly\ntype ReadonlyUser = Readonly\u003CUser>;\n\n\u002F\u002F Pick\u003CT, K> - Select specific properties\ntype UserName = Pick\u003CUser, \"name\" | \"email\">;\n\n\u002F\u002F Omit\u003CT, K> - Remove specific properties\ntype UserWithoutPassword = Omit\u003CUser, \"password\">;\n\n\u002F\u002F Exclude\u003CT, U> - Exclude types from union\ntype T1 = Exclude\u003C\"a\" | \"b\" | \"c\", \"a\">;  \u002F\u002F \"b\" | \"c\"\n\n\u002F\u002F Extract\u003CT, U> - Extract types from union\ntype T2 = Extract\u003C\"a\" | \"b\" | \"c\", \"a\" | \"b\">;  \u002F\u002F \"a\" | \"b\"\n\n\u002F\u002F NonNullable\u003CT> - Exclude null and undefined\ntype T3 = NonNullable\u003Cstring | null | undefined>;  \u002F\u002F string\n\n\u002F\u002F Record\u003CK, T> - Create object type with keys K and values T\ntype PageInfo = Record\u003C\"home\" | \"about\", { title: string }>;\n```\n\n## Advanced Patterns\n\n### Pattern 1: Type-Safe Event Emitter\n\n```typescript\ntype EventMap = {\n  \"user:created\": { id: string; name: string };\n  \"user:updated\": { id: string };\n  \"user:deleted\": { id: string };\n};\n\nclass TypedEventEmitter\u003CT extends Record\u003Cstring, any>> {\n  private listeners: {\n    [K in keyof T]?: Array\u003C(data: T[K]) => void>;\n  } = {};\n\n  on\u003CK extends keyof T>(event: K, callback: (data: T[K]) => void): void {\n    if (!this.listeners[event]) {\n      this.listeners[event] = [];\n    }\n    this.listeners[event]!.push(callback);\n  }\n\n  emit\u003CK extends keyof T>(event: K, data: T[K]): void {\n    const callbacks = this.listeners[event];\n    if (callbacks) {\n      callbacks.forEach(callback => callback(data));\n    }\n  }\n}\n\nconst emitter = new TypedEventEmitter\u003CEventMap>();\n\nemitter.on(\"user:created\", (data) => {\n  console.log(data.id, data.name);  \u002F\u002F Type-safe!\n});\n\nemitter.emit(\"user:created\", { id: \"1\", name: \"John\" });\n\u002F\u002F emitter.emit(\"user:created\", { id: \"1\" });  \u002F\u002F Error: missing 'name'\n```\n\n### Pattern 2: Type-Safe API Client\n\n```typescript\ntype HTTPMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\ntype EndpointConfig = {\n  \"\u002Fusers\": {\n    GET: { response: User[] };\n    POST: { body: { name: string; email: string }; response: User };\n  };\n  \"\u002Fusers\u002F:id\": {\n    GET: { params: { id: string }; response: User };\n    PUT: { params: { id: string }; body: Partial\u003CUser>; response: User };\n    DELETE: { params: { id: string }; response: void };\n  };\n};\n\ntype ExtractParams\u003CT> = T extends { params: infer P } ? P : never;\ntype ExtractBody\u003CT> = T extends { body: infer B } ? B : never;\ntype ExtractResponse\u003CT> = T extends { response: infer R } ? R : never;\n\nclass APIClient\u003CConfig extends Record\u003Cstring, Record\u003CHTTPMethod, any>>> {\n  async request\u003C\n    Path extends keyof Config,\n    Method extends keyof Config[Path]\n  >(\n    path: Path,\n    method: Method,\n    ...[options]: ExtractParams\u003CConfig[Path][Method]> extends never\n      ? ExtractBody\u003CConfig[Path][Method]> extends never\n        ? []\n        : [{ body: ExtractBody\u003CConfig[Path][Method]> }]\n      : [{\n          params: ExtractParams\u003CConfig[Path][Method]>;\n          body?: ExtractBody\u003CConfig[Path][Method]>;\n        }]\n  ): Promise\u003CExtractResponse\u003CConfig[Path][Method]>> {\n    \u002F\u002F Implementation here\n    return {} as any;\n  }\n}\n\nconst api = new APIClient\u003CEndpointConfig>();\n\n\u002F\u002F Type-safe API calls\nconst users = await api.request(\"\u002Fusers\", \"GET\");\n\u002F\u002F Type: User[]\n\nconst newUser = await api.request(\"\u002Fusers\", \"POST\", {\n  body: { name: \"John\", email: \"john@example.com\" }\n});\n\u002F\u002F Type: User\n\nconst user = await api.request(\"\u002Fusers\u002F:id\", \"GET\", {\n  params: { id: \"123\" }\n});\n\u002F\u002F Type: User\n```\n\n### Pattern 3: Builder Pattern with Type Safety\n\n```typescript\ntype BuilderState\u003CT> = {\n  [K in keyof T]: T[K] | undefined;\n};\n\ntype RequiredKeys\u003CT> = {\n  [K in keyof T]-?: {} extends Pick\u003CT, K> ? never : K;\n}[keyof T];\n\ntype OptionalKeys\u003CT> = {\n  [K in keyof T]-?: {} extends Pick\u003CT, K> ? K : never;\n}[keyof T];\n\ntype IsComplete\u003CT, S> =\n  RequiredKeys\u003CT> extends keyof S\n    ? S[RequiredKeys\u003CT>] extends undefined\n      ? false\n      : true\n    : false;\n\nclass Builder\u003CT, S extends BuilderState\u003CT> = {}> {\n  private state: S = {} as S;\n\n  set\u003CK extends keyof T>(\n    key: K,\n    value: T[K]\n  ): Builder\u003CT, S & Record\u003CK, T[K]>> {\n    this.state[key] = value;\n    return this as any;\n  }\n\n  build(\n    this: IsComplete\u003CT, S> extends true ? this : never\n  ): T {\n    return this.state as T;\n  }\n}\n\ninterface User {\n  id: string;\n  name: string;\n  email: string;\n  age?: number;\n}\n\nconst builder = new Builder\u003CUser>();\n\nconst user = builder\n  .set(\"id\", \"1\")\n  .set(\"name\", \"John\")\n  .set(\"email\", \"john@example.com\")\n  .build();  \u002F\u002F OK: all required fields set\n\n\u002F\u002F const incomplete = builder\n\u002F\u002F   .set(\"id\", \"1\")\n\u002F\u002F   .build();  \u002F\u002F Error: missing required fields\n```\n\n### Pattern 4: Deep Readonly\u002FPartial\n\n```typescript\ntype DeepReadonly\u003CT> = {\n  readonly [P in keyof T]: T[P] extends object\n    ? T[P] extends Function\n      ? T[P]\n      : DeepReadonly\u003CT[P]>\n    : T[P];\n};\n\ntype DeepPartial\u003CT> = {\n  [P in keyof T]?: T[P] extends object\n    ? T[P] extends Array\u003Cinfer U>\n      ? Array\u003CDeepPartial\u003CU>>\n      : DeepPartial\u003CT[P]>\n    : T[P];\n};\n\ninterface Config {\n  server: {\n    host: string;\n    port: number;\n    ssl: {\n      enabled: boolean;\n      cert: string;\n    };\n  };\n  database: {\n    url: string;\n    pool: {\n      min: number;\n      max: number;\n    };\n  };\n}\n\ntype ReadonlyConfig = DeepReadonly\u003CConfig>;\n\u002F\u002F All nested properties are readonly\n\ntype PartialConfig = DeepPartial\u003CConfig>;\n\u002F\u002F All nested properties are optional\n```\n\n### Pattern 5: Type-Safe Form Validation\n\n```typescript\ntype ValidationRule\u003CT> = {\n  validate: (value: T) => boolean;\n  message: string;\n};\n\ntype FieldValidation\u003CT> = {\n  [K in keyof T]?: ValidationRule\u003CT[K]>[];\n};\n\ntype ValidationErrors\u003CT> = {\n  [K in keyof T]?: string[];\n};\n\nclass FormValidator\u003CT extends Record\u003Cstring, any>> {\n  constructor(private rules: FieldValidation\u003CT>) {}\n\n  validate(data: T): ValidationErrors\u003CT> | null {\n    const errors: ValidationErrors\u003CT> = {};\n    let hasErrors = false;\n\n    for (const key in this.rules) {\n      const fieldRules = this.rules[key];\n      const value = data[key];\n\n      if (fieldRules) {\n        const fieldErrors: string[] = [];\n\n        for (const rule of fieldRules) {\n          if (!rule.validate(value)) {\n            fieldErrors.push(rule.message);\n          }\n        }\n\n        if (fieldErrors.length > 0) {\n          errors[key] = fieldErrors;\n          hasErrors = true;\n        }\n      }\n    }\n\n    return hasErrors ? errors : null;\n  }\n}\n\ninterface LoginForm {\n  email: string;\n  password: string;\n}\n\nconst validator = new FormValidator\u003CLoginForm>({\n  email: [\n    {\n      validate: (v) => v.includes(\"@\"),\n      message: \"Email must contain @\"\n    },\n    {\n      validate: (v) => v.length > 0,\n      message: \"Email is required\"\n    }\n  ],\n  password: [\n    {\n      validate: (v) => v.length >= 8,\n      message: \"Password must be at least 8 characters\"\n    }\n  ]\n});\n\nconst errors = validator.validate({\n  email: \"invalid\",\n  password: \"short\"\n});\n\u002F\u002F Type: { email?: string[]; password?: string[]; } | null\n```\n\n### Pattern 6: Discriminated Unions\n\n```typescript\ntype Success\u003CT> = {\n  status: \"success\";\n  data: T;\n};\n\ntype Error = {\n  status: \"error\";\n  error: string;\n};\n\ntype Loading = {\n  status: \"loading\";\n};\n\ntype AsyncState\u003CT> = Success\u003CT> | Error | Loading;\n\nfunction handleState\u003CT>(state: AsyncState\u003CT>): void {\n  switch (state.status) {\n    case \"success\":\n      console.log(state.data);  \u002F\u002F Type: T\n      break;\n    case \"error\":\n      console.log(state.error);  \u002F\u002F Type: string\n      break;\n    case \"loading\":\n      console.log(\"Loading...\");\n      break;\n  }\n}\n\n\u002F\u002F Type-safe state machine\ntype State =\n  | { type: \"idle\" }\n  | { type: \"fetching\"; requestId: string }\n  | { type: \"success\"; data: any }\n  | { type: \"error\"; error: Error };\n\ntype Event =\n  | { type: \"FETCH\"; requestId: string }\n  | { type: \"SUCCESS\"; data: any }\n  | { type: \"ERROR\"; error: Error }\n  | { type: \"RESET\" };\n\nfunction reducer(state: State, event: Event): State {\n  switch (state.type) {\n    case \"idle\":\n      return event.type === \"FETCH\"\n        ? { type: \"fetching\", requestId: event.requestId }\n        : state;\n    case \"fetching\":\n      if (event.type === \"SUCCESS\") {\n        return { type: \"success\", data: event.data };\n      }\n      if (event.type === \"ERROR\") {\n        return { type: \"error\", error: event.error };\n      }\n      return state;\n    case \"success\":\n    case \"error\":\n      return event.type === \"RESET\" ? { type: \"idle\" } : state;\n  }\n}\n```\n\n## Type Inference Techniques\n\n### 1. Infer Keyword\n\n```typescript\n\u002F\u002F Extract array element type\ntype ElementType\u003CT> = T extends (infer U)[] ? U : never;\n\ntype NumArray = number[];\ntype Num = ElementType\u003CNumArray>;  \u002F\u002F number\n\n\u002F\u002F Extract promise type\ntype PromiseType\u003CT> = T extends Promise\u003Cinfer U> ? U : never;\n\ntype AsyncNum = PromiseType\u003CPromise\u003Cnumber>>;  \u002F\u002F number\n\n\u002F\u002F Extract function parameters\ntype Parameters\u003CT> = T extends (...args: infer P) => any ? P : never;\n\nfunction foo(a: string, b: number) {}\ntype FooParams = Parameters\u003Ctypeof foo>;  \u002F\u002F [string, number]\n```\n\n### 2. Type Guards\n\n```typescript\nfunction isString(value: unknown): value is string {\n  return typeof value === \"string\";\n}\n\nfunction isArrayOf\u003CT>(\n  value: unknown,\n  guard: (item: unknown) => item is T\n): value is T[] {\n  return Array.isArray(value) && value.every(guard);\n}\n\nconst data: unknown = [\"a\", \"b\", \"c\"];\n\nif (isArrayOf(data, isString)) {\n  data.forEach(s => s.toUpperCase());  \u002F\u002F Type: string[]\n}\n```\n\n### 3. Assertion Functions\n\n```typescript\nfunction assertIsString(value: unknown): asserts value is string {\n  if (typeof value !== \"string\") {\n    throw new Error(\"Not a string\");\n  }\n}\n\nfunction processValue(value: unknown) {\n  assertIsString(value);\n  \u002F\u002F value is now typed as string\n  console.log(value.toUpperCase());\n}\n```\n\n## Best Practices\n\n1. **Use `unknown` over `any`**: Enforce type checking\n2. **Prefer `interface` for object shapes**: Better error messages\n3. **Use `type` for unions and complex types**: More flexible\n4. **Leverage type inference**: Let TypeScript infer when possible\n5. **Create helper types**: Build reusable type utilities\n6. **Use const assertions**: Preserve literal types\n7. **Avoid type assertions**: Use type guards instead\n8. **Document complex types**: Add JSDoc comments\n9. **Use strict mode**: Enable all strict compiler options\n10. **Test your types**: Use type tests to verify type behavior\n\n## Type Testing\n\n```typescript\n\u002F\u002F Type assertion tests\ntype AssertEqual\u003CT, U> =\n  [T] extends [U]\n    ? [U] extends [T]\n      ? true\n      : false\n    : false;\n\ntype Test1 = AssertEqual\u003Cstring, string>;        \u002F\u002F true\ntype Test2 = AssertEqual\u003Cstring, number>;        \u002F\u002F false\ntype Test3 = AssertEqual\u003Cstring | number, string>; \u002F\u002F false\n\n\u002F\u002F Expect error helper\ntype ExpectError\u003CT extends never> = T;\n\n\u002F\u002F Example usage\ntype ShouldError = ExpectError\u003CAssertEqual\u003Cstring, number>>;\n```\n\n## Common Pitfalls\n\n1. **Over-using `any`**: Defeats the purpose of TypeScript\n2. **Ignoring strict null checks**: Can lead to runtime errors\n3. **Too complex types**: Can slow down compilation\n4. **Not using discriminated unions**: Misses type narrowing opportunities\n5. **Forgetting readonly modifiers**: Allows unintended mutations\n6. **Circular type references**: Can cause compiler errors\n7. **Not handling edge cases**: Like empty arrays or null values\n\n## Performance Considerations\n\n- Avoid deeply nested conditional types\n- Use simple types when possible\n- Cache complex type computations\n- Limit recursion depth in recursive types\n- Use build tools to skip type checking in production\n\n## Resources\n\n- **TypeScript Handbook**: https:\u002F\u002Fwww.typescriptlang.org\u002Fdocs\u002Fhandbook\u002F\n- **Type Challenges**: https:\u002F\u002Fgithub.com\u002Ftype-challenges\u002Ftype-challenges\n- **TypeScript Deep Dive**: https:\u002F\u002Fbasarat.gitbook.io\u002Ftypescript\u002F\n- **Effective TypeScript**: Book by Dan Vanderkam\n","# TypeScript Advanced Types\n\nComprehensive guidance for mastering TypeScript's advanced type system including generics, conditional types, mapped types, template literal types, and utility types for building robust, type-safe applications.\n\n## When to Use This Skill\n\n- Building type-safe libraries or frameworks\n- Creating reusable generic components\n- Implementing complex type inference logic\n- Designing type-safe API clients\n- Building form validation systems\n- Creating strongly-typed configuration objects\n- Implementing type-safe state management\n- Migrating JavaScript codebases to TypeScript\n\n## Core Concepts\n\n### 1. Generics\n\n**Purpose:** Create reusable, type-flexible components while maintaining type safety.\n\n**Basic Generic Function:**\n```typescript\nfunction identity\u003CT>(value: T): T {\n  return value;\n}\n\nconst num = identity\u003Cnumber>(42);        \u002F\u002F Type: number\nconst str = identity\u003Cstring>(\"hello\");    \u002F\u002F Type: string\nconst auto = identity(true);              \u002F\u002F Type inferred: boolean\n```\n\n**Generic Constraints:**\n```typescript\ninterface HasLength {\n  length: number;\n}\n\nfunction logLength\u003CT extends HasLength>(item: T): T {\n  console.log(item.length);\n  return item;\n}\n\nlogLength(\"hello\");           \u002F\u002F OK: string has length\nlogLength([1, 2, 3]);         \u002F\u002F OK: array has length\nlogLength({ length: 10 });    \u002F\u002F OK: object has length\n\u002F\u002F logLength(42);             \u002F\u002F Error: number has no length\n```\n\n**Multiple Type Parameters:**\n```typescript\nfunction merge\u003CT, U>(obj1: T, obj2: U): T & U {\n  return { ...obj1, ...obj2 };\n}\n\nconst merged = merge(\n  { name: \"John\" },\n  { age: 30 }\n);\n\u002F\u002F Type: { name: string } & { age: number }\n```\n\n### 2. Conditional Types\n\n**Purpose:** Create types that depend on conditions, enabling sophisticated type logic.\n\n**Basic Conditional Type:**\n```typescript\ntype IsString\u003CT> = T extends string ? true : false;\n\ntype A = IsString\u003Cstring>;    \u002F\u002F true\ntype B = IsString\u003Cnumber>;    \u002F\u002F false\n```\n\n**Extracting Return Types:**\n```typescript\ntype ReturnType\u003CT> = T extends (...args: any[]) => infer R ? R : never;\n\nfunction getUser() {\n  return { id: 1, name: \"John\" };\n}\n\ntype User = ReturnType\u003Ctypeof getUser>;\n\u002F\u002F Type: { id: number; name: string; }\n```\n\n**Distributive Conditional Types:**\n```typescript\ntype ToArray\u003CT> = T extends any ? T[] : never;\n\ntype StrOrNumArray = ToArray\u003Cstring | number>;\n\u002F\u002F Type: string[] | number[]\n```\n\n**Nested Conditions:**\n```typescript\ntype TypeName\u003CT> =\n  T extends string ? \"string\" :\n  T extends number ? \"number\" :\n  T extends boolean ? \"boolean\" :\n  T extends undefined ? \"undefined\" :\n  T extends Function ? \"function\" :\n  \"object\";\n\ntype T1 = TypeName\u003Cstring>;     \u002F\u002F \"string\"\ntype T2 = TypeName\u003C() => void>; \u002F\u002F \"function\"\n```\n\n### 3. Mapped Types\n\n**Purpose:** Transform existing types by iterating over their properties.\n\n**Basic Mapped Type:**\n```typescript\ntype Readonly\u003CT> = {\n  readonly [P in keyof T]: T[P];\n};\n\ninterface User {\n  id: number;\n  name: string;\n}\n\ntype ReadonlyUser = Readonly\u003CUser>;\n\u002F\u002F Type: { readonly id: number; readonly name: string; }\n```\n\n**Optional Properties:**\n```typescript\ntype Partial\u003CT> = {\n  [P in keyof T]?: T[P];\n};\n\ntype PartialUser = Partial\u003CUser>;\n\u002F\u002F Type: { id?: number; name?: string; }\n```\n\n**Key Remapping:**\n```typescript\ntype Getters\u003CT> = {\n  [K in keyof T as `get${Capitalize\u003Cstring & K>}`]: () => T[K]\n};\n\ninterface Person {\n  name: string;\n  age: number;\n}\n\ntype PersonGetters = Getters\u003CPerson>;\n\u002F\u002F Type: { getName: () => string; getAge: () => number; }\n```\n\n**Filtering Properties:**\n```typescript\ntype PickByType\u003CT, U> = {\n  [K in keyof T as T[K] extends U ? K : never]: T[K]\n};\n\ninterface Mixed {\n  id: number;\n  name: string;\n  age: number;\n  active: boolean;\n}\n\ntype OnlyNumbers = PickByType\u003CMixed, number>;\n\u002F\u002F Type: { id: number; age: number; }\n```\n\n### 4. Template Literal Types\n\n**Purpose:** Create string-based types with pattern matching and transformation.\n\n**Basic Template Literal:**\n```typescript\ntype EventName = \"click\" | \"focus\" | \"blur\";\ntype EventHandler = `on${Capitalize\u003CEventName>}`;\n\u002F\u002F Type: \"onClick\" | \"onFocus\" | \"onBlur\"\n```\n\n**String Manipulation:**\n```typescript\ntype UppercaseGreeting = Uppercase\u003C\"hello\">;  \u002F\u002F \"HELLO\"\ntype LowercaseGreeting = Lowercase\u003C\"HELLO\">;  \u002F\u002F \"hello\"\ntype CapitalizedName = Capitalize\u003C\"john\">;    \u002F\u002F \"John\"\ntype UncapitalizedName = Uncapitalize\u003C\"John\">; \u002F\u002F \"john\"\n```\n\n**Path Building:**\n```typescript\ntype Path\u003CT> = T extends object\n  ? { [K in keyof T]: K extends string\n      ? `${K}` | `${K}.${Path\u003CT[K]>}`\n      : never\n    }[keyof T]\n  : never;\n\ninterface Config {\n  server: {\n    host: string;\n    port: number;\n  };\n  database: {\n    url: string;\n  };\n}\n\ntype ConfigPath = Path\u003CConfig>;\n\u002F\u002F Type: \"server\" | \"database\" | \"server.host\" | \"server.port\" | \"database.url\"\n```\n\n### 5. Utility Types\n\n**Built-in Utility Types:**\n\n```typescript\n\u002F\u002F Partial\u003CT> - Make all properties optional\ntype PartialUser = Partial\u003CUser>;\n\n\u002F\u002F Required\u003CT> - Make all properties required\ntype RequiredUser = Required\u003CPartialUser>;\n\n\u002F\u002F Readonly\u003CT> - Make all properties readonly\ntype ReadonlyUser = Readonly\u003CUser>;\n\n\u002F\u002F Pick\u003CT, K> - Select specific properties\ntype UserName = Pick\u003CUser, \"name\" | \"email\">;\n\n\u002F\u002F Omit\u003CT, K> - Remove specific properties\ntype UserWithoutPassword = Omit\u003CUser, \"password\">;\n\n\u002F\u002F Exclude\u003CT, U> - Exclude types from union\ntype T1 = Exclude\u003C\"a\" | \"b\" | \"c\", \"a\">;  \u002F\u002F \"b\" | \"c\"\n\n\u002F\u002F Extract\u003CT, U> - Extract types from union\ntype T2 = Extract\u003C\"a\" | \"b\" | \"c\", \"a\" | \"b\">;  \u002F\u002F \"a\" | \"b\"\n\n\u002F\u002F NonNullable\u003CT> - Exclude null and undefined\ntype T3 = NonNullable\u003Cstring | null | undefined>;  \u002F\u002F string\n\n\u002F\u002F Record\u003CK, T> - Create object type with keys K and values T\ntype PageInfo = Record\u003C\"home\" | \"about\", { title: string }>;\n```\n\n## Advanced Patterns\n\n### Pattern 1: Type-Safe Event Emitter\n\n```typescript\ntype EventMap = {\n  \"user:created\": { id: string; name: string };\n  \"user:updated\": { id: string };\n  \"user:deleted\": { id: string };\n};\n\nclass TypedEventEmitter\u003CT extends Record\u003Cstring, any>> {\n  private listeners: {\n    [K in keyof T]?: Array\u003C(data: T[K]) => void>;\n  } = {};\n\n  on\u003CK extends keyof T>(event: K, callback: (data: T[K]) => void): void {\n    if (!this.listeners[event]) {\n      this.listeners[event] = [];\n    }\n    this.listeners[event]!.push(callback);\n  }\n\n  emit\u003CK extends keyof T>(event: K, data: T[K]): void {\n    const callbacks = this.listeners[event];\n    if (callbacks) {\n      callbacks.forEach(callback => callback(data));\n    }\n  }\n}\n\nconst emitter = new TypedEventEmitter\u003CEventMap>();\n\nemitter.on(\"user:created\", (data) => {\n  console.log(data.id, data.name);  \u002F\u002F Type-safe!\n});\n\nemitter.emit(\"user:created\", { id: \"1\", name: \"John\" });\n\u002F\u002F emitter.emit(\"user:created\", { id: \"1\" });  \u002F\u002F Error: missing 'name'\n```\n\n### Pattern 2: Type-Safe API Client\n\n```typescript\ntype HTTPMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\ntype EndpointConfig = {\n  \"\u002Fusers\": {\n    GET: { response: User[] };\n    POST: { body: { name: string; email: string }; response: User };\n  };\n  \"\u002Fusers\u002F:id\": {\n    GET: { params: { id: string }; response: User };\n    PUT: { params: { id: string }; body: Partial\u003CUser>; response: User };\n    DELETE: { params: { id: string }; response: void };\n  };\n};\n\ntype ExtractParams\u003CT> = T extends { params: infer P } ? P : never;\ntype ExtractBody\u003CT> = T extends { body: infer B } ? B : never;\ntype ExtractResponse\u003CT> = T extends { response: infer R } ? R : never;\n\nclass APIClient\u003CConfig extends Record\u003Cstring, Record\u003CHTTPMethod, any>>> {\n  async request\u003C\n    Path extends keyof Config,\n    Method extends keyof Config[Path]\n  >(\n    path: Path,\n    method: Method,\n    ...[options]: ExtractParams\u003CConfig[Path][Method]> extends never\n      ? ExtractBody\u003CConfig[Path][Method]> extends never\n        ? []\n        : [{ body: ExtractBody\u003CConfig[Path][Method]> }]\n      : [{\n          params: ExtractParams\u003CConfig[Path][Method]>;\n          body?: ExtractBody\u003CConfig[Path][Method]>;\n        }]\n  ): Promise\u003CExtractResponse\u003CConfig[Path][Method]>> {\n    \u002F\u002F Implementation here\n    return {} as any;\n  }\n}\n\nconst api = new APIClient\u003CEndpointConfig>();\n\n\u002F\u002F Type-safe API calls\nconst users = await api.request(\"\u002Fusers\", \"GET\");\n\u002F\u002F Type: User[]\n\nconst newUser = await api.request(\"\u002Fusers\", \"POST\", {\n  body: { name: \"John\", email: \"john@example.com\" }\n});\n\u002F\u002F Type: User\n\nconst user = await api.request(\"\u002Fusers\u002F:id\", \"GET\", {\n  params: { id: \"123\" }\n});\n\u002F\u002F Type: User\n```\n\n### Pattern 3: Builder Pattern with Type Safety\n\n```typescript\ntype BuilderState\u003CT> = {\n  [K in keyof T]: T[K] | undefined;\n};\n\ntype RequiredKeys\u003CT> = {\n  [K in keyof T]-?: {} extends Pick\u003CT, K> ? never : K;\n}[keyof T];\n\ntype OptionalKeys\u003CT> = {\n  [K in keyof T]-?: {} extends Pick\u003CT, K> ? K : never;\n}[keyof T];\n\ntype IsComplete\u003CT, S> =\n  RequiredKeys\u003CT> extends keyof S\n    ? S[RequiredKeys\u003CT>] extends undefined\n      ? false\n      : true\n    : false;\n\nclass Builder\u003CT, S extends BuilderState\u003CT> = {}> {\n  private state: S = {} as S;\n\n  set\u003CK extends keyof T>(\n    key: K,\n    value: T[K]\n  ): Builder\u003CT, S & Record\u003CK, T[K]>> {\n    this.state[key] = value;\n    return this as any;\n  }\n\n  build(\n    this: IsComplete\u003CT, S> extends true ? this : never\n  ): T {\n    return this.state as T;\n  }\n}\n\ninterface User {\n  id: string;\n  name: string;\n  email: string;\n  age?: number;\n}\n\nconst builder = new Builder\u003CUser>();\n\nconst user = builder\n  .set(\"id\", \"1\")\n  .set(\"name\", \"John\")\n  .set(\"email\", \"john@example.com\")\n  .build();  \u002F\u002F OK: all required fields set\n\n\u002F\u002F const incomplete = builder\n\u002F\u002F   .set(\"id\", \"1\")\n\u002F\u002F   .build();  \u002F\u002F Error: missing required fields\n```\n\n### Pattern 4: Deep Readonly\u002FPartial\n\n```typescript\ntype DeepReadonly\u003CT> = {\n  readonly [P in keyof T]: T[P] extends object\n    ? T[P] extends Function\n      ? T[P]\n      : DeepReadonly\u003CT[P]>\n    : T[P];\n};\n\ntype DeepPartial\u003CT> = {\n  [P in keyof T]?: T[P] extends object\n    ? T[P] extends Array\u003Cinfer U>\n      ? Array\u003CDeepPartial\u003CU>>\n      : DeepPartial\u003CT[P]>\n    : T[P];\n};\n\ninterface Config {\n  server: {\n    host: string;\n    port: number;\n    ssl: {\n      enabled: boolean;\n      cert: string;\n    };\n  };\n  database: {\n    url: string;\n    pool: {\n      min: number;\n      max: number;\n    };\n  };\n}\n\ntype ReadonlyConfig = DeepReadonly\u003CConfig>;\n\u002F\u002F All nested properties are readonly\n\ntype PartialConfig = DeepPartial\u003CConfig>;\n\u002F\u002F All nested properties are optional\n```\n\n### Pattern 5: Type-Safe Form Validation\n\n```typescript\ntype ValidationRule\u003CT> = {\n  validate: (value: T) => boolean;\n  message: string;\n};\n\ntype FieldValidation\u003CT> = {\n  [K in keyof T]?: ValidationRule\u003CT[K]>[];\n};\n\ntype ValidationErrors\u003CT> = {\n  [K in keyof T]?: string[];\n};\n\nclass FormValidator\u003CT extends Record\u003Cstring, any>> {\n  constructor(private rules: FieldValidation\u003CT>) {}\n\n  validate(data: T): ValidationErrors\u003CT> | null {\n    const errors: ValidationErrors\u003CT> = {};\n    let hasErrors = false;\n\n    for (const key in this.rules) {\n      const fieldRules = this.rules[key];\n      const value = data[key];\n\n      if (fieldRules) {\n        const fieldErrors: string[] = [];\n\n        for (const rule of fieldRules) {\n          if (!rule.validate(value)) {\n            fieldErrors.push(rule.message);\n          }\n        }\n\n        if (fieldErrors.length > 0) {\n          errors[key] = fieldErrors;\n          hasErrors = true;\n        }\n      }\n    }\n\n    return hasErrors ? errors : null;\n  }\n}\n\ninterface LoginForm {\n  email: string;\n  password: string;\n}\n\nconst validator = new FormValidator\u003CLoginForm>({\n  email: [\n    {\n      validate: (v) => v.includes(\"@\"),\n      message: \"Email must contain @\"\n    },\n    {\n      validate: (v) => v.length > 0,\n      message: \"Email is required\"\n    }\n  ],\n  password: [\n    {\n      validate: (v) => v.length >= 8,\n      message: \"Password must be at least 8 characters\"\n    }\n  ]\n});\n\nconst errors = validator.validate({\n  email: \"invalid\",\n  password: \"short\"\n});\n\u002F\u002F Type: { email?: string[]; password?: string[]; } | null\n```\n\n### Pattern 6: Discriminated Unions\n\n```typescript\ntype Success\u003CT> = {\n  status: \"success\";\n  data: T;\n};\n\ntype Error = {\n  status: \"error\";\n  error: string;\n};\n\ntype Loading = {\n  status: \"loading\";\n};\n\ntype AsyncState\u003CT> = Success\u003CT> | Error | Loading;\n\nfunction handleState\u003CT>(state: AsyncState\u003CT>): void {\n  switch (state.status) {\n    case \"success\":\n      console.log(state.data);  \u002F\u002F Type: T\n      break;\n    case \"error\":\n      console.log(state.error);  \u002F\u002F Type: string\n      break;\n    case \"loading\":\n      console.log(\"Loading...\");\n      break;\n  }\n}\n\n\u002F\u002F Type-safe state machine\ntype State =\n  | { type: \"idle\" }\n  | { type: \"fetching\"; requestId: string }\n  | { type: \"success\"; data: any }\n  | { type: \"error\"; error: Error };\n\ntype Event =\n  | { type: \"FETCH\"; requestId: string }\n  | { type: \"SUCCESS\"; data: any }\n  | { type: \"ERROR\"; error: Error }\n  | { type: \"RESET\" };\n\nfunction reducer(state: State, event: Event): State {\n  switch (state.type) {\n    case \"idle\":\n      return event.type === \"FETCH\"\n        ? { type: \"fetching\", requestId: event.requestId }\n        : state;\n    case \"fetching\":\n      if (event.type === \"SUCCESS\") {\n        return { type: \"success\", data: event.data };\n      }\n      if (event.type === \"ERROR\") {\n        return { type: \"error\", error: event.error };\n      }\n      return state;\n    case \"success\":\n    case \"error\":\n      return event.type === \"RESET\" ? { type: \"idle\" } : state;\n  }\n}\n```\n\n## Type Inference Techniques\n\n### 1. Infer Keyword\n\n```typescript\n\u002F\u002F Extract array element type\ntype ElementType\u003CT> = T extends (infer U)[] ? U : never;\n\ntype NumArray = number[];\ntype Num = ElementType\u003CNumArray>;  \u002F\u002F number\n\n\u002F\u002F Extract promise type\ntype PromiseType\u003CT> = T extends Promise\u003Cinfer U> ? U : never;\n\ntype AsyncNum = PromiseType\u003CPromise\u003Cnumber>>;  \u002F\u002F number\n\n\u002F\u002F Extract function parameters\ntype Parameters\u003CT> = T extends (...args: infer P) => any ? P : never;\n\nfunction foo(a: string, b: number) {}\ntype FooParams = Parameters\u003Ctypeof foo>;  \u002F\u002F [string, number]\n```\n\n### 2. Type Guards\n\n```typescript\nfunction isString(value: unknown): value is string {\n  return typeof value === \"string\";\n}\n\nfunction isArrayOf\u003CT>(\n  value: unknown,\n  guard: (item: unknown) => item is T\n): value is T[] {\n  return Array.isArray(value) && value.every(guard);\n}\n\nconst data: unknown = [\"a\", \"b\", \"c\"];\n\nif (isArrayOf(data, isString)) {\n  data.forEach(s => s.toUpperCase());  \u002F\u002F Type: string[]\n}\n```\n\n### 3. Assertion Functions\n\n```typescript\nfunction assertIsString(value: unknown): asserts value is string {\n  if (typeof value !== \"string\") {\n    throw new Error(\"Not a string\");\n  }\n}\n\nfunction processValue(value: unknown) {\n  assertIsString(value);\n  \u002F\u002F value is now typed as string\n  console.log(value.toUpperCase());\n}\n```\n\n## Best Practices\n\n1. **Use `unknown` over `any`**: Enforce type checking\n2. **Prefer `interface` for object shapes**: Better error messages\n3. **Use `type` for unions and complex types**: More flexible\n4. **Leverage type inference**: Let TypeScript infer when possible\n5. **Create helper types**: Build reusable type utilities\n6. **Use const assertions**: Preserve literal types\n7. **Avoid type assertions**: Use type guards instead\n8. **Document complex types**: Add JSDoc comments\n9. **Use strict mode**: Enable all strict compiler options\n10. **Test your types**: Use type tests to verify type behavior\n\n## Type Testing\n\n```typescript\n\u002F\u002F Type assertion tests\ntype AssertEqual\u003CT, U> =\n  [T] extends [U]\n    ? [U] extends [T]\n      ? true\n      : false\n    : false;\n\ntype Test1 = AssertEqual\u003Cstring, string>;        \u002F\u002F true\ntype Test2 = AssertEqual\u003Cstring, number>;        \u002F\u002F false\ntype Test3 = AssertEqual\u003Cstring | number, string>; \u002F\u002F false\n\n\u002F\u002F Expect error helper\ntype ExpectError\u003CT extends never> = T;\n\n\u002F\u002F Example usage\ntype ShouldError = ExpectError\u003CAssertEqual\u003Cstring, number>>;\n```\n\n## Common Pitfalls\n\n1. **Over-using `any`**: Defeats the purpose of TypeScript\n2. **Ignoring strict null checks**: Can lead to runtime errors\n3. **Too complex types**: Can slow down compilation\n4. **Not using discriminated unions**: Misses type narrowing opportunities\n5. **Forgetting readonly modifiers**: Allows unintended mutations\n6. **Circular type references**: Can cause compiler errors\n7. **Not handling edge cases**: Like empty arrays or null values\n\n## Performance Considerations\n\n- Avoid deeply nested conditional types\n- Use simple types when possible\n- Cache complex type computations\n- Limit recursion depth in recursive types\n- Use build tools to skip type checking in production\n\n## Resources\n\n- **TypeScript Handbook**: https:\u002F\u002Fwww.typescriptlang.org\u002Fdocs\u002Fhandbook\u002F\n- **Type Challenges**: https:\u002F\u002Fgithub.com\u002Ftype-challenges\u002Ftype-challenges\n- **TypeScript Deep Dive**: https:\u002F\u002Fbasarat.gitbook.io\u002Ftypescript\u002F\n- **Effective TypeScript**: Book by Dan Vanderkam\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-Plugin-插件协议\u002FYYC3-Plugin-插件协议-external_plugins\u002Fjavascript-typescript\u002Fskills\u002Ftypescript-advanced-types",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill typescript-advanced-types",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill typescript-advanced-types",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill typescript-advanced-types","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Plugin-插件协议\u002FYYC3-Plugin-插件协议-external_plugins\u002Fjavascript-typescript\u002Fskills\u002Ftypescript-advanced-types\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]