[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C91TV7ZN5P70Q4FDKEGECX":3,"skill-same:01M7C91TV7ZN5P70Q4FDKEGECX":110},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":13,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":53,"install":54,"resources":67},"01M7C91TV7ZN5P70Q4FDKEGECX","mastering-typescript",null,"Master enterprise-grade TypeScript development with type-safe patterns, modern tooling, and framework integration. This skill provides comprehensive guidance for TypeScript 5.9+, covering type system fundamentals (generics, mapped types, conditional types, satisfies operator), enterprise patterns (error handling, validation with Zod), React integration for type-safe frontends, NestJS for scalable APIs, and LangChain.js for AI applications. Use when building type-safe applications, migrating JavaScript codebases, configuring modern toolchains (Vite 7, pnpm, ESLint, Vitest), implementing advanced type patterns, or comparing TypeScript with Java\u002FPython approaches.","andyandsmoothies-ship-it\u002Fvtcoon","andyandsmoothies-ship-it","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F252826565?v=4","01M7C8ZEHYQ9WNQRWESPJFCQ8Y","01M7C8ZEJJZVNH6JSM4NS5WJ4J",0,"MIT","https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: mastering-typescript\ndescription: |\n  Master enterprise-grade TypeScript development with type-safe patterns, modern tooling, and framework integration. This skill provides comprehensive guidance for TypeScript 5.9+, covering type system fundamentals (generics, mapped types, conditional types, satisfies operator), enterprise patterns (error handling, validation with Zod), React integration for type-safe frontends, NestJS for scalable APIs, and LangChain.js for AI applications. Use when building type-safe applications, migrating JavaScript codebases, configuring modern toolchains (Vite 7, pnpm, ESLint, Vitest), implementing advanced type patterns, or comparing TypeScript with Java\u002FPython approaches.\nversion: 1.0.0\ncategory: programming-languages\ntriggers:\n  - typescript\n  - ts\n  - type-safe\n  - generics\n  - nestjs typescript\n  - react typescript\n  - typescript migration\n  - tsconfig\n  - type guards\n  - mapped types\n  - conditional types\n  - satisfies operator\n  - zod validation\nauthor: Richard Hightower\nlicense: MIT\ntags:\n  - typescript\n  - type-safety\n  - enterprise\n  - react\n  - nestjs\n  - langchain\n  - vite\n---\n\n# Mastering Modern TypeScript\n\nBuild enterprise-grade, type-safe applications with TypeScript 5.9+.\n\n> **Compatibility:** TypeScript 5.9+, Node.js 22 LTS, Vite 7, NestJS 11, React 19\n\n## Quick Start\n\n```bash\n# Initialize TypeScript project with ESM\npnpm create vite@latest my-app --template vanilla-ts\ncd my-app && pnpm install\n\n# Configure strict TypeScript\ncat > tsconfig.json \u003C\u003C 'EOF'\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2024\",\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"bundler\",\n    \"strict\": true,\n    \"noUncheckedIndexedAccess\": true,\n    \"exactOptionalPropertyTypes\": true,\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true\n  }\n}\nEOF\n```\n\n## When to Use This Skill\n\nUse when:\n- Building type-safe React, NestJS, or Node.js applications\n- Migrating JavaScript codebases to TypeScript\n- Implementing advanced type patterns (generics, mapped types, conditional types)\n- Configuring modern TypeScript toolchains (Vite, pnpm, ESLint)\n- Designing type-safe API contracts with Zod validation\n- Comparing TypeScript approaches with Java or Python\n\n## Project Setup Checklist\n\nBefore starting any TypeScript project:\n\n```\n- [ ] Use pnpm for package management (faster, disk-efficient)\n- [ ] Configure ESM-first (type: \"module\" in package.json)\n- [ ] Enable strict mode in tsconfig.json\n- [ ] Set up ESLint with @typescript-eslint\n- [ ] Add Prettier for consistent formatting\n- [ ] Configure Vitest for testing\n```\n\n## Type System Quick Reference\n\n### Primitive Types\n\n```typescript\nconst name: string = \"Alice\";\nconst age: number = 30;\nconst active: boolean = true;\nconst id: bigint = 9007199254740991n;\nconst key: symbol = Symbol(\"unique\");\n```\n\n### Union and Intersection Types\n\n```typescript\n\u002F\u002F Union: value can be one of several types\ntype Status = \"pending\" | \"approved\" | \"rejected\";\n\n\u002F\u002F Intersection: value must satisfy all types\ntype Employee = Person & { employeeId: string };\n\n\u002F\u002F Discriminated union for type-safe handling\ntype Result\u003CT> =\n  | { success: true; data: T }\n  | { success: false; error: string };\n\nfunction handleResult\u003CT>(result: Result\u003CT>): T | null {\n  if (result.success) {\n    return result.data; \u002F\u002F TypeScript knows data exists here\n  }\n  console.error(result.error);\n  return null;\n}\n```\n\n### Type Guards\n\n```typescript\n\u002F\u002F typeof guard\nfunction process(value: string | number): string {\n  if (typeof value === \"string\") {\n    return value.toUpperCase();\n  }\n  return value.toFixed(2);\n}\n\n\u002F\u002F Custom type guard\ninterface User { type: \"user\"; name: string }\ninterface Admin { type: \"admin\"; permissions: string[] }\n\nfunction isAdmin(person: User | Admin): person is Admin {\n  return person.type === \"admin\";\n}\n```\n\n### The `satisfies` Operator (TS 5.0+)\n\nValidate type conformance while preserving inference:\n\n```typescript\n\u002F\u002F Problem: Type assertion loses specific type info\nconst colors1 = {\n  red: \"#ff0000\",\n  green: \"#00ff00\"\n} as Record\u003Cstring, string>;\n\ncolors1.red.toUpperCase(); \u002F\u002F OK, but red could be undefined\n\n\u002F\u002F Solution: satisfies preserves literal types\nconst colors2 = {\n  red: \"#ff0000\",\n  green: \"#00ff00\"\n} satisfies Record\u003Cstring, string>;\n\ncolors2.red.toUpperCase(); \u002F\u002F OK, and TypeScript knows red exists\n```\n\n## Generics Patterns\n\n### Basic Generic Function\n\n```typescript\nfunction first\u003CT>(items: T[]): T | undefined {\n  return items[0];\n}\n\nconst num = first([1, 2, 3]);     \u002F\u002F number | undefined\nconst str = first([\"a\", \"b\"]);   \u002F\u002F string | undefined\n```\n\n### Constrained Generics\n\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(42);          \u002F\u002F Error: number has no length\n```\n\n### Generic API Response Wrapper\n\n```typescript\ninterface ApiResponse\u003CT> {\n  data: T;\n  status: number;\n  timestamp: Date;\n}\n\nasync function fetchUser(id: string): Promise\u003CApiResponse\u003CUser>> {\n  const response = await fetch(`\u002Fapi\u002Fusers\u002F${id}`);\n  const data = await response.json();\n  return {\n    data,\n    status: response.status,\n    timestamp: new Date()\n  };\n}\n```\n\n## Utility Types Reference\n\n| Type | Purpose | Example |\n|------|---------|---------|\n| `Partial\u003CT>` | All properties optional | `Partial\u003CUser>` |\n| `Required\u003CT>` | All properties required | `Required\u003CConfig>` |\n| `Pick\u003CT, K>` | Select specific properties | `Pick\u003CUser, \"id\" \\| \"name\">` |\n| `Omit\u003CT, K>` | Exclude specific properties | `Omit\u003CUser, \"password\">` |\n| `Record\u003CK, V>` | Object with typed keys\u002Fvalues | `Record\u003Cstring, number>` |\n| `ReturnType\u003CF>` | Extract function return type | `ReturnType\u003Ctypeof fn>` |\n| `Parameters\u003CF>` | Extract function parameters | `Parameters\u003Ctypeof fn>` |\n| `Awaited\u003CT>` | Unwrap Promise type | `Awaited\u003CPromise\u003CUser>>` |\n\n## Conditional Types\n\n```typescript\n\u002F\u002F Basic conditional type\ntype IsString\u003CT> = T extends string ? true : false;\n\n\u002F\u002F Extract array element type\ntype ArrayElement\u003CT> = T extends (infer E)[] ? E : never;\n\ntype Numbers = ArrayElement\u003Cnumber[]>; \u002F\u002F number\ntype Strings = ArrayElement\u003Cstring[]>; \u002F\u002F string\n\n\u002F\u002F Practical: Extract Promise result type\ntype UnwrapPromise\u003CT> = T extends Promise\u003Cinfer R> ? R : T;\n```\n\n## Mapped Types\n\n```typescript\n\u002F\u002F Make all properties readonly\ntype Immutable\u003CT> = {\n  readonly [K in keyof T]: T[K];\n};\n\n\u002F\u002F Make all properties nullable\ntype Nullable\u003CT> = {\n  [K in keyof T]: T[K] | null;\n};\n\n\u002F\u002F Create getter functions for each property\ntype Getters\u003CT> = {\n  [K in keyof T as `get${Capitalize\u003Cstring & K>}`]: () => T[K];\n};\n\ninterface Person { name: string; age: number }\ntype PersonGetters = Getters\u003CPerson>;\n\u002F\u002F { getName: () => string; getAge: () => number }\n```\n\n## Framework Integration\n\n### React with TypeScript\n\n```typescript\n\u002F\u002F Typed functional component\ninterface ButtonProps {\n  label: string;\n  onClick: () => void;\n  variant?: \"primary\" | \"secondary\";\n}\n\nconst Button: React.FC\u003CButtonProps> = ({ label, onClick, variant = \"primary\" }) => (\n  \u003Cbutton className={variant} onClick={onClick}>\n    {label}\n  \u003C\u002Fbutton>\n);\n\n\u002F\u002F Typed hooks\nconst [count, setCount] = useState\u003Cnumber>(0);\nconst userRef = useRef\u003CHTMLInputElement>(null);\n```\n\n### NestJS with TypeScript\n\n```typescript\n\u002F\u002F Type-safe DTO with class-validator\nimport { IsString, IsEmail, MinLength } from 'class-validator';\n\nclass CreateUserDto {\n  @IsString()\n  @MinLength(2)\n  name: string;\n\n  @IsEmail()\n  email: string;\n}\n\n\u002F\u002F Or with Zod (modern approach)\nimport { z } from 'zod';\n\nconst CreateUserSchema = z.object({\n  name: z.string().min(2),\n  email: z.string().email()\n});\n\ntype CreateUserDto = z.infer\u003Ctypeof CreateUserSchema>;\n```\n\nSee [react-integration.md](references\u002Freact-integration.md) and [nestjs-integration.md](references\u002Fnestjs-integration.md) for detailed patterns.\n\n## Validation with Zod\n\n```typescript\nimport { z } from 'zod';\n\n\u002F\u002F Define schema\nconst UserSchema = z.object({\n  id: z.string().uuid(),\n  name: z.string().min(1).max(100),\n  email: z.string().email(),\n  role: z.enum([\"user\", \"admin\", \"moderator\"]),\n  createdAt: z.coerce.date()\n});\n\n\u002F\u002F Infer TypeScript type from schema\ntype User = z.infer\u003Ctypeof UserSchema>;\n\n\u002F\u002F Validate at runtime\nfunction parseUser(data: unknown): User {\n  return UserSchema.parse(data); \u002F\u002F Throws ZodError if invalid\n}\n\n\u002F\u002F Safe parsing (returns result object)\nconst result = UserSchema.safeParse(data);\nif (result.success) {\n  console.log(result.data); \u002F\u002F Typed as User\n} else {\n  console.error(result.error.issues);\n}\n```\n\n## Modern Toolchain (2025)\n\n| Tool | Version | Purpose |\n|------|---------|---------|\n| TypeScript | 5.9+ | Type checking and compilation |\n| Node.js | 22 LTS | Runtime environment |\n| Vite | 7.x | Build tool and dev server |\n| pnpm | 9.x | Package manager |\n| ESLint | 9.x | Linting with flat config |\n| Vitest | 3.x | Testing framework |\n| Prettier | 3.x | Code formatting |\n\n### ESLint Flat Config (ESLint 9+)\n\n```javascript\n\u002F\u002F eslint.config.js\nimport eslint from '@eslint\u002Fjs';\nimport tseslint from 'typescript-eslint';\n\nexport default tseslint.config(\n  eslint.configs.recommended,\n  ...tseslint.configs.strictTypeChecked,\n  {\n    languageOptions: {\n      parserOptions: {\n        projectService: true,\n        tsconfigRootDir: import.meta.dirname,\n      },\n    },\n  }\n);\n```\n\n## Migration Strategies\n\n### Incremental Migration\n\n1. Add `allowJs: true` and `checkJs: false` to tsconfig.json\n2. Rename files from `.js` to `.ts` one at a time\n3. Add type annotations gradually\n4. Enable stricter options incrementally\n\n### JSDoc for Gradual Typing\n\n```javascript\n\u002F\u002F Before full migration, use JSDoc\n\u002F**\n * @param {string} name\n * @param {number} age\n * @returns {User}\n *\u002F\nfunction createUser(name, age) {\n  return { name, age };\n}\n```\n\nSee [enterprise-patterns.md](references\u002Fenterprise-patterns.md) for comprehensive migration guides.\n\n## Common Mistakes\n\n| Mistake | Problem | Fix |\n|---------|---------|-----|\n| Using `any` liberally | Defeats type safety | Use `unknown` and narrow |\n| Ignoring strict mode | Misses null\u002Fundefined bugs | Enable all strict options |\n| Type assertions (`as`) | Can hide type errors | Use `satisfies` or guards |\n| Enum for simple unions | Generates runtime code | Use literal unions instead |\n| Not validating API data | Runtime type mismatches | Use Zod at boundaries |\n\n## Cross-Language Comparison\n\n| Feature | TypeScript | Java | Python |\n|---------|------------|------|--------|\n| Type System | Structural | Nominal | Gradual (duck typing) |\n| Nullability | Explicit (`T \\| null`) | `@Nullable` annotations | Optional via typing |\n| Generics | Type-level, erased | Type-level, erased | Runtime via typing |\n| Interfaces | Structural matching | Must implement | Protocol (3.8+) |\n| Enums | Avoid (use unions) | First-class | Enum class |\n\n## Reference Files\n\n- [type-system.md](references\u002Ftype-system.md) — Complete type system guide\n- [generics.md](references\u002Fgenerics.md) — Advanced generics patterns\n- [enterprise-patterns.md](references\u002Fenterprise-patterns.md) — Error handling, validation, architecture\n- [react-integration.md](references\u002Freact-integration.md) — React + TypeScript patterns\n- [nestjs-integration.md](references\u002Fnestjs-integration.md) — NestJS API development\n- [toolchain.md](references\u002Ftoolchain.md) — Modern build tools configuration\n\n## Assets\n\n- [tsconfig-template.json](assets\u002Ftsconfig-template.json) — Strict enterprise config\n- [eslint-template.js](assets\u002Feslint-template.js) — ESLint 9 flat config\n\n## Scripts\n\n- [validate-setup.sh](scripts\u002Fvalidate-setup.sh) — Verify TypeScript environment\n","# Mastering Modern TypeScript\n\nBuild enterprise-grade, type-safe applications with TypeScript 5.9+.\n\n> **Compatibility:** TypeScript 5.9+, Node.js 22 LTS, Vite 7, NestJS 11, React 19\n\n## Quick Start\n\n```bash\n# Initialize TypeScript project with ESM\npnpm create vite@latest my-app --template vanilla-ts\ncd my-app && pnpm install\n\n# Configure strict TypeScript\ncat > tsconfig.json \u003C\u003C 'EOF'\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2024\",\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"bundler\",\n    \"strict\": true,\n    \"noUncheckedIndexedAccess\": true,\n    \"exactOptionalPropertyTypes\": true,\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true\n  }\n}\nEOF\n```\n\n## When to Use This Skill\n\nUse when:\n- Building type-safe React, NestJS, or Node.js applications\n- Migrating JavaScript codebases to TypeScript\n- Implementing advanced type patterns (generics, mapped types, conditional types)\n- Configuring modern TypeScript toolchains (Vite, pnpm, ESLint)\n- Designing type-safe API contracts with Zod validation\n- Comparing TypeScript approaches with Java or Python\n\n## Project Setup Checklist\n\nBefore starting any TypeScript project:\n\n```\n- [ ] Use pnpm for package management (faster, disk-efficient)\n- [ ] Configure ESM-first (type: \"module\" in package.json)\n- [ ] Enable strict mode in tsconfig.json\n- [ ] Set up ESLint with @typescript-eslint\n- [ ] Add Prettier for consistent formatting\n- [ ] Configure Vitest for testing\n```\n\n## Type System Quick Reference\n\n### Primitive Types\n\n```typescript\nconst name: string = \"Alice\";\nconst age: number = 30;\nconst active: boolean = true;\nconst id: bigint = 9007199254740991n;\nconst key: symbol = Symbol(\"unique\");\n```\n\n### Union and Intersection Types\n\n```typescript\n\u002F\u002F Union: value can be one of several types\ntype Status = \"pending\" | \"approved\" | \"rejected\";\n\n\u002F\u002F Intersection: value must satisfy all types\ntype Employee = Person & { employeeId: string };\n\n\u002F\u002F Discriminated union for type-safe handling\ntype Result\u003CT> =\n  | { success: true; data: T }\n  | { success: false; error: string };\n\nfunction handleResult\u003CT>(result: Result\u003CT>): T | null {\n  if (result.success) {\n    return result.data; \u002F\u002F TypeScript knows data exists here\n  }\n  console.error(result.error);\n  return null;\n}\n```\n\n### Type Guards\n\n```typescript\n\u002F\u002F typeof guard\nfunction process(value: string | number): string {\n  if (typeof value === \"string\") {\n    return value.toUpperCase();\n  }\n  return value.toFixed(2);\n}\n\n\u002F\u002F Custom type guard\ninterface User { type: \"user\"; name: string }\ninterface Admin { type: \"admin\"; permissions: string[] }\n\nfunction isAdmin(person: User | Admin): person is Admin {\n  return person.type === \"admin\";\n}\n```\n\n### The `satisfies` Operator (TS 5.0+)\n\nValidate type conformance while preserving inference:\n\n```typescript\n\u002F\u002F Problem: Type assertion loses specific type info\nconst colors1 = {\n  red: \"#ff0000\",\n  green: \"#00ff00\"\n} as Record\u003Cstring, string>;\n\ncolors1.red.toUpperCase(); \u002F\u002F OK, but red could be undefined\n\n\u002F\u002F Solution: satisfies preserves literal types\nconst colors2 = {\n  red: \"#ff0000\",\n  green: \"#00ff00\"\n} satisfies Record\u003Cstring, string>;\n\ncolors2.red.toUpperCase(); \u002F\u002F OK, and TypeScript knows red exists\n```\n\n## Generics Patterns\n\n### Basic Generic Function\n\n```typescript\nfunction first\u003CT>(items: T[]): T | undefined {\n  return items[0];\n}\n\nconst num = first([1, 2, 3]);     \u002F\u002F number | undefined\nconst str = first([\"a\", \"b\"]);   \u002F\u002F string | undefined\n```\n\n### Constrained Generics\n\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(42);          \u002F\u002F Error: number has no length\n```\n\n### Generic API Response Wrapper\n\n```typescript\ninterface ApiResponse\u003CT> {\n  data: T;\n  status: number;\n  timestamp: Date;\n}\n\nasync function fetchUser(id: string): Promise\u003CApiResponse\u003CUser>> {\n  const response = await fetch(`\u002Fapi\u002Fusers\u002F${id}`);\n  const data = await response.json();\n  return {\n    data,\n    status: response.status,\n    timestamp: new Date()\n  };\n}\n```\n\n## Utility Types Reference\n\n| Type | Purpose | Example |\n|------|---------|---------|\n| `Partial\u003CT>` | All properties optional | `Partial\u003CUser>` |\n| `Required\u003CT>` | All properties required | `Required\u003CConfig>` |\n| `Pick\u003CT, K>` | Select specific properties | `Pick\u003CUser, \"id\" \\| \"name\">` |\n| `Omit\u003CT, K>` | Exclude specific properties | `Omit\u003CUser, \"password\">` |\n| `Record\u003CK, V>` | Object with typed keys\u002Fvalues | `Record\u003Cstring, number>` |\n| `ReturnType\u003CF>` | Extract function return type | `ReturnType\u003Ctypeof fn>` |\n| `Parameters\u003CF>` | Extract function parameters | `Parameters\u003Ctypeof fn>` |\n| `Awaited\u003CT>` | Unwrap Promise type | `Awaited\u003CPromise\u003CUser>>` |\n\n## Conditional Types\n\n```typescript\n\u002F\u002F Basic conditional type\ntype IsString\u003CT> = T extends string ? true : false;\n\n\u002F\u002F Extract array element type\ntype ArrayElement\u003CT> = T extends (infer E)[] ? E : never;\n\ntype Numbers = ArrayElement\u003Cnumber[]>; \u002F\u002F number\ntype Strings = ArrayElement\u003Cstring[]>; \u002F\u002F string\n\n\u002F\u002F Practical: Extract Promise result type\ntype UnwrapPromise\u003CT> = T extends Promise\u003Cinfer R> ? R : T;\n```\n\n## Mapped Types\n\n```typescript\n\u002F\u002F Make all properties readonly\ntype Immutable\u003CT> = {\n  readonly [K in keyof T]: T[K];\n};\n\n\u002F\u002F Make all properties nullable\ntype Nullable\u003CT> = {\n  [K in keyof T]: T[K] | null;\n};\n\n\u002F\u002F Create getter functions for each property\ntype Getters\u003CT> = {\n  [K in keyof T as `get${Capitalize\u003Cstring & K>}`]: () => T[K];\n};\n\ninterface Person { name: string; age: number }\ntype PersonGetters = Getters\u003CPerson>;\n\u002F\u002F { getName: () => string; getAge: () => number }\n```\n\n## Framework Integration\n\n### React with TypeScript\n\n```typescript\n\u002F\u002F Typed functional component\ninterface ButtonProps {\n  label: string;\n  onClick: () => void;\n  variant?: \"primary\" | \"secondary\";\n}\n\nconst Button: React.FC\u003CButtonProps> = ({ label, onClick, variant = \"primary\" }) => (\n  \u003Cbutton className={variant} onClick={onClick}>\n    {label}\n  \u003C\u002Fbutton>\n);\n\n\u002F\u002F Typed hooks\nconst [count, setCount] = useState\u003Cnumber>(0);\nconst userRef = useRef\u003CHTMLInputElement>(null);\n```\n\n### NestJS with TypeScript\n\n```typescript\n\u002F\u002F Type-safe DTO with class-validator\nimport { IsString, IsEmail, MinLength } from 'class-validator';\n\nclass CreateUserDto {\n  @IsString()\n  @MinLength(2)\n  name: string;\n\n  @IsEmail()\n  email: string;\n}\n\n\u002F\u002F Or with Zod (modern approach)\nimport { z } from 'zod';\n\nconst CreateUserSchema = z.object({\n  name: z.string().min(2),\n  email: z.string().email()\n});\n\ntype CreateUserDto = z.infer\u003Ctypeof CreateUserSchema>;\n```\n\nSee [react-integration.md](references\u002Freact-integration.md) and [nestjs-integration.md](references\u002Fnestjs-integration.md) for detailed patterns.\n\n## Validation with Zod\n\n```typescript\nimport { z } from 'zod';\n\n\u002F\u002F Define schema\nconst UserSchema = z.object({\n  id: z.string().uuid(),\n  name: z.string().min(1).max(100),\n  email: z.string().email(),\n  role: z.enum([\"user\", \"admin\", \"moderator\"]),\n  createdAt: z.coerce.date()\n});\n\n\u002F\u002F Infer TypeScript type from schema\ntype User = z.infer\u003Ctypeof UserSchema>;\n\n\u002F\u002F Validate at runtime\nfunction parseUser(data: unknown): User {\n  return UserSchema.parse(data); \u002F\u002F Throws ZodError if invalid\n}\n\n\u002F\u002F Safe parsing (returns result object)\nconst result = UserSchema.safeParse(data);\nif (result.success) {\n  console.log(result.data); \u002F\u002F Typed as User\n} else {\n  console.error(result.error.issues);\n}\n```\n\n## Modern Toolchain (2025)\n\n| Tool | Version | Purpose |\n|------|---------|---------|\n| TypeScript | 5.9+ | Type checking and compilation |\n| Node.js | 22 LTS | Runtime environment |\n| Vite | 7.x | Build tool and dev server |\n| pnpm | 9.x | Package manager |\n| ESLint | 9.x | Linting with flat config |\n| Vitest | 3.x | Testing framework |\n| Prettier | 3.x | Code formatting |\n\n### ESLint Flat Config (ESLint 9+)\n\n```javascript\n\u002F\u002F eslint.config.js\nimport eslint from '@eslint\u002Fjs';\nimport tseslint from 'typescript-eslint';\n\nexport default tseslint.config(\n  eslint.configs.recommended,\n  ...tseslint.configs.strictTypeChecked,\n  {\n    languageOptions: {\n      parserOptions: {\n        projectService: true,\n        tsconfigRootDir: import.meta.dirname,\n      },\n    },\n  }\n);\n```\n\n## Migration Strategies\n\n### Incremental Migration\n\n1. Add `allowJs: true` and `checkJs: false` to tsconfig.json\n2. Rename files from `.js` to `.ts` one at a time\n3. Add type annotations gradually\n4. Enable stricter options incrementally\n\n### JSDoc for Gradual Typing\n\n```javascript\n\u002F\u002F Before full migration, use JSDoc\n\u002F**\n * @param {string} name\n * @param {number} age\n * @returns {User}\n *\u002F\nfunction createUser(name, age) {\n  return { name, age };\n}\n```\n\nSee [enterprise-patterns.md](references\u002Fenterprise-patterns.md) for comprehensive migration guides.\n\n## Common Mistakes\n\n| Mistake | Problem | Fix |\n|---------|---------|-----|\n| Using `any` liberally | Defeats type safety | Use `unknown` and narrow |\n| Ignoring strict mode | Misses null\u002Fundefined bugs | Enable all strict options |\n| Type assertions (`as`) | Can hide type errors | Use `satisfies` or guards |\n| Enum for simple unions | Generates runtime code | Use literal unions instead |\n| Not validating API data | Runtime type mismatches | Use Zod at boundaries |\n\n## Cross-Language Comparison\n\n| Feature | TypeScript | Java | Python |\n|---------|------------|------|--------|\n| Type System | Structural | Nominal | Gradual (duck typing) |\n| Nullability | Explicit (`T \\| null`) | `@Nullable` annotations | Optional via typing |\n| Generics | Type-level, erased | Type-level, erased | Runtime via typing |\n| Interfaces | Structural matching | Must implement | Protocol (3.8+) |\n| Enums | Avoid (use unions) | First-class | Enum class |\n\n## Reference Files\n\n- [type-system.md](references\u002Ftype-system.md) — Complete type system guide\n- [generics.md](references\u002Fgenerics.md) — Advanced generics patterns\n- [enterprise-patterns.md](references\u002Fenterprise-patterns.md) — Error handling, validation, architecture\n- [react-integration.md](references\u002Freact-integration.md) — React + TypeScript patterns\n- [nestjs-integration.md](references\u002Fnestjs-integration.md) — NestJS API development\n- [toolchain.md](references\u002Ftoolchain.md) — Modern build tools configuration\n\n## Assets\n\n- [tsconfig-template.json](assets\u002Ftsconfig-template.json) — Strict enterprise config\n- [eslint-template.js](assets\u002Feslint-template.js) — ESLint 9 flat config\n\n## Scripts\n\n- [validate-setup.sh](scripts\u002Fvalidate-setup.sh) — Verify TypeScript environment\n",{"name":5,"tags":23,"author":31,"license":14,"version":32,"category":33,"triggers":34,"description":47},[24,25,26,27,28,29,30],"typescript","type-safety","enterprise","react","nestjs","langchain","vite","Richard Hightower","1.0.0","programming-languages",[24,35,36,37,38,39,40,41,42,43,44,45,46],"ts","type-safe","generics","nestjs typescript","react typescript","typescript migration","tsconfig","type guards","mapped types","conditional types","satisfies operator","zod validation","Master enterprise-grade TypeScript development with type-safe patterns, modern tooling, and framework integration. This skill provides comprehensive guidance for TypeScript 5.9+, covering type system fundamentals (generics, mapped types, conditional types, satisfies operator), enterprise patterns (error handling, validation with Zod), React integration for type-safe frontends, NestJS for scalable APIs, and LangChain.js for AI applications. Use when building type-safe applications, migrating JavaScript codebases, configuring modern toolchains (Vite 7, pnpm, ESLint, Vitest), implementing advanced type patterns, or comparing TypeScript with Java\u002FPython approaches.\n","main","dd2fe80639a632fa676dfae4ac8cf44d31482ef1",".agents\u002Fskills\u002Fmastering-typescript","https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon","https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it","2026-11-03 18:24:15",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add andyandsmoothies-ship-it\u002Fvtcoon --skill mastering-typescript",{"tool":60,"command":61},"bunx","bunx skills add andyandsmoothies-ship-it\u002Fvtcoon --skill mastering-typescript",{"tool":63,"command":64},"pnpm","pnpm dlx skills add andyandsmoothies-ship-it\u002Fvtcoon --skill mastering-typescript","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002FSKILL.md",true,[68,74,80,86,90,94,98,102,106],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"assets\u002Feslint-template.js","SCRIPT","脚本",2193,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Fassets\u002Feslint-template.js",{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"assets\u002Ftsconfig-template.json","ASSET","资产文件",1167,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Fassets\u002Ftsconfig-template.json",{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fenterprise-patterns.md","REFERENCE","参考文档",11926,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Freferences\u002Fenterprise-patterns.md",{"path":87,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fgenerics.md",11659,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Freferences\u002Fgenerics.md",{"path":91,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fnestjs-integration.md",14602,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Freferences\u002Fnestjs-integration.md",{"path":95,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Freact-integration.md",13743,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Freferences\u002Freact-integration.md",{"path":99,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Ftoolchain.md",11023,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Freferences\u002Ftoolchain.md",{"path":103,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Ftype-system.md",10031,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Freferences\u002Ftype-system.md",{"path":107,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":108,"sourceHtmlUrl":109},"scripts\u002Fvalidate-setup.sh",5708,"https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fmastering-typescript\u002Fscripts\u002Fvalidate-setup.sh",[111],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":18},"01M7C96EXSDT7DC6GXFTJJ7WXJ","react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002Fandyandsmoothies-ship-it\u002Fvtcoon\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Freact-best-practices\u002FSKILL.md",[],[]]