[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DW222PHDNJ8QC34GQ8K8BM":3,"skill-same:01M6DW222PHDNJ8QC34GQ8K8BM":76},{"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":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":6,"ownerHtmlUrl":45,"ownerBlogUrl":46,"ownerDescription":6,"updatedAt":47,"install":48,"resources":61},"01M6DW222PHDNJ8QC34GQ8K8BM","ts-conventions",null,"ACTIVATE when writing TypeScript types, generics, branded types, discriminated unions, or configuring tsconfig. ACTIVATE for 'type vs interface', 'enum alternative', 'branded type', 'satisfies', 'strict mode'. Covers: strict mode policy, no-any\u002Fno-enum rules, type over interface, discriminated unions, satisfies operator, branded types for ID safety, utility types. DO NOT use for: code formatting (see ts-code-conventions), functional patterns (see ts-functional).","FabienSalles\u002Fclaude-marketplace","FabienSalles","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F937901?v=4","01M6DVJBD31CJKRB382FQFZ5FH","Fabien Salles","01M6DVJBQNY8Q18KJD1ESAD6TX",9,"MIT","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-conventions\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"conventions","ts conventions","writing","typescript","policy","code","operator","Safety","Rules","use","activate","do","patterns","formatting","type","id","2026-11-10 10:12:30",false,"---\nname: ts-conventions\ndescription: \"ACTIVATE when writing TypeScript types, generics, branded types, discriminated unions, or configuring tsconfig. ACTIVATE for 'type vs interface', 'enum alternative', 'branded type', 'satisfies', 'strict mode'. Covers: strict mode policy, no-any\u002Fno-enum rules, type over interface, discriminated unions, satisfies operator, branded types for ID safety, utility types. DO NOT use for: code formatting (see ts-code-conventions), functional patterns (see ts-functional).\"\n---\n\n# TypeScript Conventions\n\n## Strict Mode\n\n**`strict: true` is mandatory** in `tsconfig.json`: without it, the whole convention set below is unenforceable — `no any`, discriminated unions, branded types all rely on the compiler actually checking null, implicit any, and type narrowing. No exceptions.\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"strict\": true,\n    \u002F\u002F Array\u002Fobject index access returns `T | undefined` instead of `T`,\n    \u002F\u002F so a missing key fails to compile instead of crashing at runtime.\n    \"noUncheckedIndexedAccess\": true,\n    \u002F\u002F An optional property (`foo?: string`) can no longer be set to\n    \u002F\u002F `undefined` explicitly — it must be omitted, catching typos like\n    \u002F\u002F `{ foo: undefined }` where `foo` was meant to be left out.\n    \"exactOptionalPropertyTypes\": true\n  }\n}\n```\n\n`strict: true` is set once, at the repo root, and no package's own `tsconfig.json` may set it back to `false` to relax the check for that package alone.\n\nCost: a package `tsconfig.json` that relaxes `strict` silently loses `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes` along with it, so a missing array index compiles clean inside that package and only crashes once another package imports it.\n\n## No `any` — Use `unknown` + Narrowing\n\n```typescript\n\u002F\u002F ❌ AVOID - any bypasses all type checking\nfunction parse(input: any): string {\n  return input.name; \u002F\u002F No error, but crashes if input has no name\n}\n\n\u002F\u002F ✅ CORRECT - unknown forces explicit narrowing\nfunction parse(input: unknown): string {\n  if (typeof input === 'object' && input !== null && 'name' in input) {\n    return String(input.name);\n  }\n\n  throw new Error('Invalid input');\n}\n```\n\n`unknown` replaces `any` only at a boundary that receives untyped data — a parsed HTTP body, `JSON.parse`, a third-party callback — never inside code the domain already typed.\n\nCost: an `any` that survives past the parse boundary propagates through every function it touches, so the narrowing done three call sites downstream stops meaning anything.\n\n## No Inline `typeof import(...)` — Use `import type`\n\n```typescript\n\u002F\u002F ❌ AVOID - Inline typeof import is unreadable and bypasses proper imports\nconst service = new MyService(\n  mock as unknown as InstanceType\u003C\n    typeof import('..\u002Fpath\u002Fto\u002Frepository').Repository\n  >,\n);\n\n\u002F\u002F ✅ CORRECT - Import the type at the top of the file\nimport type { Repository } from '..\u002Fpath\u002Fto\u002Frepository';\n\nconst service = new MyService(\n  mock as unknown as Repository,\n);\n```\n\n`import type` applies to every import kept only for its type, not just the `typeof import(...)` pattern shown above.\n\nCost: a value import kept only for its type still pulls the whole module into the runtime bundle — the compiler considers it used, so tree-shaking cannot remove it.\n\n## No `enum` — Use `as const`\n\n```typescript\n\u002F\u002F ❌ AVOID - TypeScript enums have quirks (reverse mapping, runtime code)\nenum Status {\n  Active = 'active',\n  Inactive = 'inactive',\n}\n\n\u002F\u002F ✅ CORRECT - as const + type union\nconst STATUS = {\n  Active: 'active',\n  Inactive: 'inactive',\n} as const;\n\ntype Status = (typeof STATUS)[keyof typeof STATUS]; \u002F\u002F 'active' | 'inactive'\n```\n\nas const serves exactly two purposes: freezing a closed set to derive a union, and pinning a module constant to its literal type.\n\n## Closed Set as a Triplet\n\nA closed set is written as a triplet in a single file: the as const object, the derived union, and the predicate.\n\n```typescript\nconst RECEIPT_STATUS = {\n  Draft: 'draft',\n  Sent: 'sent',\n} as const;\n\ntype ReceiptStatus = (typeof RECEIPT_STATUS)[keyof typeof RECEIPT_STATUS];\n\nconst isReceiptStatus = (value: string): value is ReceiptStatus =>\n  Object.values(RECEIPT_STATUS).includes(value as ReceiptStatus);\n```\n\n## `type` vs `interface`\n\n**Use `type` by default.** Use `interface` only when declaration merging or `extends` is needed (e.g., for NestJS class-based DI). The type-over-interface convention is enforced by ESLint's naming-convention rule, not by code review.\n\n```typescript\n\u002F\u002F ✅ type — for most cases\ntype Receipt = {\n  id: string;\n  amount: number;\n  period: Period;\n};\n\n\u002F\u002F ✅ interface — when merging or extending is needed\ninterface CreateTenantDto {\n  email: string;\n  firstName: string;\n}\n\ninterface UpdateTenantDto extends Partial\u003CCreateTenantDto> {\n  id: string;\n}\n```\n\n## Discriminated Unions\n\n**Model exclusive states explicitly** — no impossible combinations:\n\n```typescript\n\u002F\u002F ❌ AVOID - Both fields optional = 4 possible states, only 2 are valid\ntype Receipt = {\n  data?: ReceiptData;\n  error?: string;\n};\n\n\u002F\u002F ✅ CORRECT - Discriminated union = only valid states\ntype Receipt =\n  | { tag: 'fetched'; data: ReceiptData }\n  | { tag: 'not-fetched'; error: string };\n\nfunction isFetched(receipt: Receipt): receipt is Extract\u003CReceipt, { tag: 'fetched' }> {\n  return receipt.tag === 'fetched';\n}\n\nfunction handle(receipt: Receipt) {\n  if (isFetched(receipt)) {\n    console.log(receipt.data); \u002F\u002F TypeScript knows data exists\n  } else {\n    console.error(receipt.error); \u002F\u002F TypeScript knows error exists\n  }\n}\n```\n\nThe discriminant field is always named tag, and callers use isX predicates instead of comparing tag directly.\n\n> **The `Result\u003CT, E>` discriminated union for fallible operations is owned by `ts-functional`** — do not redefine it here.\n\n## `satisfies` Operator\n\n**Use `satisfies` to validate a value matches a type without widening it:**\n\n```typescript\ntype RouteConfig = Record\u003Cstring, { path: string; auth: boolean }>;\n\n\u002F\u002F ❌ Type annotation widens — loses literal types\nconst routes: RouteConfig = {\n  home: { path: '\u002F', auth: false },\n  dashboard: { path: '\u002Fdashboard', auth: true },\n};\nroutes.home.path; \u002F\u002F type: string (widened)\n\n\u002F\u002F ✅ satisfies — validates AND preserves literal types\nconst routes = {\n  home: { path: '\u002F', auth: false },\n  dashboard: { path: '\u002Fdashboard', auth: true },\n} satisfies RouteConfig;\nroutes.home.path; \u002F\u002F type: '\u002F' (preserved)\n```\n\nsatisfies checks a rendered or collected object literal's shape without widening it; it is never used to validate an untyped value.\n\n## Branded Types\n\n**Prevent accidental swaps** of primitive types that represent different concepts. A brand adds no data, so it can only ever be asserted — which is why the assertion is written **once**, in the kernel, and never in the domain:\n\n```typescript\n\u002F\u002F kernel\u002Fbrand.ts — the one place in the codebase that asserts a brand\ndeclare const brand: unique symbol;\n\nexport type Brand\u003CT, B extends string> = T & { readonly [brand]: B };\nexport const mint = \u003CB extends string>() => \u003CT>(value: T): Brand\u003CT, B> => value as Brand\u003CT, B>;\n```\n\n```typescript\n\u002F\u002F domain — no `as` here, and nothing outside can forge one\ntype TenantId = Brand\u003Cstring, 'TenantId'>;\ntype LandlordId = Brand\u003Cstring, 'LandlordId'>;\n\nconst toTenantId = mint\u003C'TenantId'>();\nconst toLandlordId = mint\u003C'LandlordId'>();\n\n\u002F\u002F ❌ Compile error — cannot mix branded types\nfunction getReceipts(landlordId: LandlordId): Receipt[] { ... }\ngetReceipts(toTenantId('abc')); \u002F\u002F Type error!\n```\n\nThe brand key is a `unique symbol` that is never exported, so no caller can hand-write `{ ...value, __brand: 'TenantId' }` and forge the proof. A string-literal key such as `string & { readonly __brand: 'TenantId' }` is addressable, which makes passing through the factory optional — and a proof that is optional is not a proof.\n\nas is tolerated only at infrastructure boundaries: external payloads, JSON.parse, SDK calls, empty accumulators; inside the domain it is debt.\n\n> **See also**: `ts-oop`'s \"TS-specific: Branded Types for Primitive Identifiers\" heading for branded types in value objects.\n\n## Utility Types\n\n`Pick`, `Omit`, and `Partial` derive a DTO or a command shape from an aggregate; the aggregate itself is never expressed as a `Partial`.\n\nCost: an aggregate typed as `Partial\u003CTenant>` for a command payload lets a caller construct it missing the very fields the constructor was written to guarantee, moving the invariant back to code review.\n\n```typescript\n\u002F\u002F Pick specific properties\ntype TenantSummary = Pick\u003CTenant, 'id' | 'email' | 'firstName'>;\n\n\u002F\u002F Omit properties\ntype CreateTenant = Omit\u003CTenant, 'id' | 'createdAt' | 'updatedAt'>;\n\n\u002F\u002F Make all properties optional\ntype PartialTenant = Partial\u003CTenant>;\n\n\u002F\u002F Make all properties required\ntype RequiredTenant = Required\u003CTenant>;\n\n\u002F\u002F Read-only\ntype FrozenTenant = Readonly\u003CTenant>;\n\n\u002F\u002F Record\ntype TenantMap = Record\u003CTenantId, Tenant>;\n```\n\n## Generics\n\n```typescript\n\u002F\u002F ✅ CORRECT - Constrained generics\nfunction findById\u003CT extends { id: string }>(items: T[], id: string): T | undefined {\n  return items.find(item => item.id === id);\n}\n\n\u002F\u002F ✅ CORRECT - Generic with default\ntype ApiResponse\u003CT = unknown> = {\n  data: T;\n  meta: { timestamp: string };\n};\n```\n\nAn unconstrained `\u003CT>` is reserved to structural containers such as `ApiResponse` above; a domain function's generic always carries a semantic constraint (`extends { id: string }`, `extends DomainError`, …).\n\nCost: an unconstrained `\u003CT>` on a domain function accepts any shape at all, so a typo'd field name on the call site fails at runtime instead of at the call.\n\n## Nullability Patterns\n\n```typescript\n\u002F\u002F ✅ Explicit return types for nullable\nfunction findTenant(id: string): Tenant | null { ... }\n\n\u002F\u002F ✅ Non-null assertion only when truly guaranteed\nconst element = document.getElementById('root')!; \u002F\u002F Only in entry points\n\n\u002F\u002F ❌ AVOID - Non-null assertion to silence compiler\nconst tenant = findTenant(id)!; \u002F\u002F Use narrowing instead\n\n\u002F\u002F ✅ CORRECT - Narrowing\nconst tenant = findTenant(id);\n\nif (tenant === null) {\n  throw new NotFoundException('Tenant not found');\n}\n\n\u002F\u002F tenant is now Tenant (narrowed)\n```\n\nAbsence in a domain type is written as an explicit | null; ? is reserved for external payload shapes and partial update commands.\n\nThe non-null assertion `!` is reserved to a framework entry point — application bootstrap, DI container resolution — never to a domain handler or service.\n\n## Command and Query Handler Typing\n\nOn the Command side, publish a named function-type alias after the handler's file and annotate the factory with it; on the Query side, let it infer.\n\nThe exported handler type alias lives in the handler's own file, never centralized in a shared `types.ts` barrel.\n\n```typescript\n\u002F\u002F createReceipt.ts\nexport type CreateReceiptHandler = (command: CreateReceiptCommand) => AsyncResult\u003CReceipt, DomainError>;\n\nconst createReceipt: CreateReceiptHandler = (command) => { ... };\n\n\u002F\u002F findReceiptById.ts — Query, no alias, inferred return type\nconst findReceiptById = (query: FindReceiptByIdQuery) => { ... };\n```\n\n## Quick Reference\n\n| Rule | Convention |\n|------|-----------|\n| Strict mode | `strict: true`, always |\n| No `any` | Use `unknown` + narrowing |\n| No `typeof import(...)` | Use `import type` at top of file |\n| No `enum` | Use `as const` + type union |\n| type vs interface | `type` by default, `interface` for merging\u002Fextends |\n| Exclusive states | Discriminated unions |\n| Value validation | `satisfies` to preserve literal types |\n| ID safety | `Brand\u003CT, B>`, minted once in the kernel, never asserted in the domain |\n| Subsets | `Pick`, `Omit`, `Partial`, `Required` |\n| Nullability | Explicit `| null`, narrowing over `!` |\n","# TypeScript Conventions\n\n## Strict Mode\n\n**`strict: true` is mandatory** in `tsconfig.json`: without it, the whole convention set below is unenforceable — `no any`, discriminated unions, branded types all rely on the compiler actually checking null, implicit any, and type narrowing. No exceptions.\n\n```jsonc\n{\n  \"compilerOptions\": {\n    \"strict\": true,\n    \u002F\u002F Array\u002Fobject index access returns `T | undefined` instead of `T`,\n    \u002F\u002F so a missing key fails to compile instead of crashing at runtime.\n    \"noUncheckedIndexedAccess\": true,\n    \u002F\u002F An optional property (`foo?: string`) can no longer be set to\n    \u002F\u002F `undefined` explicitly — it must be omitted, catching typos like\n    \u002F\u002F `{ foo: undefined }` where `foo` was meant to be left out.\n    \"exactOptionalPropertyTypes\": true\n  }\n}\n```\n\n`strict: true` is set once, at the repo root, and no package's own `tsconfig.json` may set it back to `false` to relax the check for that package alone.\n\nCost: a package `tsconfig.json` that relaxes `strict` silently loses `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes` along with it, so a missing array index compiles clean inside that package and only crashes once another package imports it.\n\n## No `any` — Use `unknown` + Narrowing\n\n```typescript\n\u002F\u002F ❌ AVOID - any bypasses all type checking\nfunction parse(input: any): string {\n  return input.name; \u002F\u002F No error, but crashes if input has no name\n}\n\n\u002F\u002F ✅ CORRECT - unknown forces explicit narrowing\nfunction parse(input: unknown): string {\n  if (typeof input === 'object' && input !== null && 'name' in input) {\n    return String(input.name);\n  }\n\n  throw new Error('Invalid input');\n}\n```\n\n`unknown` replaces `any` only at a boundary that receives untyped data — a parsed HTTP body, `JSON.parse`, a third-party callback — never inside code the domain already typed.\n\nCost: an `any` that survives past the parse boundary propagates through every function it touches, so the narrowing done three call sites downstream stops meaning anything.\n\n## No Inline `typeof import(...)` — Use `import type`\n\n```typescript\n\u002F\u002F ❌ AVOID - Inline typeof import is unreadable and bypasses proper imports\nconst service = new MyService(\n  mock as unknown as InstanceType\u003C\n    typeof import('..\u002Fpath\u002Fto\u002Frepository').Repository\n  >,\n);\n\n\u002F\u002F ✅ CORRECT - Import the type at the top of the file\nimport type { Repository } from '..\u002Fpath\u002Fto\u002Frepository';\n\nconst service = new MyService(\n  mock as unknown as Repository,\n);\n```\n\n`import type` applies to every import kept only for its type, not just the `typeof import(...)` pattern shown above.\n\nCost: a value import kept only for its type still pulls the whole module into the runtime bundle — the compiler considers it used, so tree-shaking cannot remove it.\n\n## No `enum` — Use `as const`\n\n```typescript\n\u002F\u002F ❌ AVOID - TypeScript enums have quirks (reverse mapping, runtime code)\nenum Status {\n  Active = 'active',\n  Inactive = 'inactive',\n}\n\n\u002F\u002F ✅ CORRECT - as const + type union\nconst STATUS = {\n  Active: 'active',\n  Inactive: 'inactive',\n} as const;\n\ntype Status = (typeof STATUS)[keyof typeof STATUS]; \u002F\u002F 'active' | 'inactive'\n```\n\nas const serves exactly two purposes: freezing a closed set to derive a union, and pinning a module constant to its literal type.\n\n## Closed Set as a Triplet\n\nA closed set is written as a triplet in a single file: the as const object, the derived union, and the predicate.\n\n```typescript\nconst RECEIPT_STATUS = {\n  Draft: 'draft',\n  Sent: 'sent',\n} as const;\n\ntype ReceiptStatus = (typeof RECEIPT_STATUS)[keyof typeof RECEIPT_STATUS];\n\nconst isReceiptStatus = (value: string): value is ReceiptStatus =>\n  Object.values(RECEIPT_STATUS).includes(value as ReceiptStatus);\n```\n\n## `type` vs `interface`\n\n**Use `type` by default.** Use `interface` only when declaration merging or `extends` is needed (e.g., for NestJS class-based DI). The type-over-interface convention is enforced by ESLint's naming-convention rule, not by code review.\n\n```typescript\n\u002F\u002F ✅ type — for most cases\ntype Receipt = {\n  id: string;\n  amount: number;\n  period: Period;\n};\n\n\u002F\u002F ✅ interface — when merging or extending is needed\ninterface CreateTenantDto {\n  email: string;\n  firstName: string;\n}\n\ninterface UpdateTenantDto extends Partial\u003CCreateTenantDto> {\n  id: string;\n}\n```\n\n## Discriminated Unions\n\n**Model exclusive states explicitly** — no impossible combinations:\n\n```typescript\n\u002F\u002F ❌ AVOID - Both fields optional = 4 possible states, only 2 are valid\ntype Receipt = {\n  data?: ReceiptData;\n  error?: string;\n};\n\n\u002F\u002F ✅ CORRECT - Discriminated union = only valid states\ntype Receipt =\n  | { tag: 'fetched'; data: ReceiptData }\n  | { tag: 'not-fetched'; error: string };\n\nfunction isFetched(receipt: Receipt): receipt is Extract\u003CReceipt, { tag: 'fetched' }> {\n  return receipt.tag === 'fetched';\n}\n\nfunction handle(receipt: Receipt) {\n  if (isFetched(receipt)) {\n    console.log(receipt.data); \u002F\u002F TypeScript knows data exists\n  } else {\n    console.error(receipt.error); \u002F\u002F TypeScript knows error exists\n  }\n}\n```\n\nThe discriminant field is always named tag, and callers use isX predicates instead of comparing tag directly.\n\n> **The `Result\u003CT, E>` discriminated union for fallible operations is owned by `ts-functional`** — do not redefine it here.\n\n## `satisfies` Operator\n\n**Use `satisfies` to validate a value matches a type without widening it:**\n\n```typescript\ntype RouteConfig = Record\u003Cstring, { path: string; auth: boolean }>;\n\n\u002F\u002F ❌ Type annotation widens — loses literal types\nconst routes: RouteConfig = {\n  home: { path: '\u002F', auth: false },\n  dashboard: { path: '\u002Fdashboard', auth: true },\n};\nroutes.home.path; \u002F\u002F type: string (widened)\n\n\u002F\u002F ✅ satisfies — validates AND preserves literal types\nconst routes = {\n  home: { path: '\u002F', auth: false },\n  dashboard: { path: '\u002Fdashboard', auth: true },\n} satisfies RouteConfig;\nroutes.home.path; \u002F\u002F type: '\u002F' (preserved)\n```\n\nsatisfies checks a rendered or collected object literal's shape without widening it; it is never used to validate an untyped value.\n\n## Branded Types\n\n**Prevent accidental swaps** of primitive types that represent different concepts. A brand adds no data, so it can only ever be asserted — which is why the assertion is written **once**, in the kernel, and never in the domain:\n\n```typescript\n\u002F\u002F kernel\u002Fbrand.ts — the one place in the codebase that asserts a brand\ndeclare const brand: unique symbol;\n\nexport type Brand\u003CT, B extends string> = T & { readonly [brand]: B };\nexport const mint = \u003CB extends string>() => \u003CT>(value: T): Brand\u003CT, B> => value as Brand\u003CT, B>;\n```\n\n```typescript\n\u002F\u002F domain — no `as` here, and nothing outside can forge one\ntype TenantId = Brand\u003Cstring, 'TenantId'>;\ntype LandlordId = Brand\u003Cstring, 'LandlordId'>;\n\nconst toTenantId = mint\u003C'TenantId'>();\nconst toLandlordId = mint\u003C'LandlordId'>();\n\n\u002F\u002F ❌ Compile error — cannot mix branded types\nfunction getReceipts(landlordId: LandlordId): Receipt[] { ... }\ngetReceipts(toTenantId('abc')); \u002F\u002F Type error!\n```\n\nThe brand key is a `unique symbol` that is never exported, so no caller can hand-write `{ ...value, __brand: 'TenantId' }` and forge the proof. A string-literal key such as `string & { readonly __brand: 'TenantId' }` is addressable, which makes passing through the factory optional — and a proof that is optional is not a proof.\n\nas is tolerated only at infrastructure boundaries: external payloads, JSON.parse, SDK calls, empty accumulators; inside the domain it is debt.\n\n> **See also**: `ts-oop`'s \"TS-specific: Branded Types for Primitive Identifiers\" heading for branded types in value objects.\n\n## Utility Types\n\n`Pick`, `Omit`, and `Partial` derive a DTO or a command shape from an aggregate; the aggregate itself is never expressed as a `Partial`.\n\nCost: an aggregate typed as `Partial\u003CTenant>` for a command payload lets a caller construct it missing the very fields the constructor was written to guarantee, moving the invariant back to code review.\n\n```typescript\n\u002F\u002F Pick specific properties\ntype TenantSummary = Pick\u003CTenant, 'id' | 'email' | 'firstName'>;\n\n\u002F\u002F Omit properties\ntype CreateTenant = Omit\u003CTenant, 'id' | 'createdAt' | 'updatedAt'>;\n\n\u002F\u002F Make all properties optional\ntype PartialTenant = Partial\u003CTenant>;\n\n\u002F\u002F Make all properties required\ntype RequiredTenant = Required\u003CTenant>;\n\n\u002F\u002F Read-only\ntype FrozenTenant = Readonly\u003CTenant>;\n\n\u002F\u002F Record\ntype TenantMap = Record\u003CTenantId, Tenant>;\n```\n\n## Generics\n\n```typescript\n\u002F\u002F ✅ CORRECT - Constrained generics\nfunction findById\u003CT extends { id: string }>(items: T[], id: string): T | undefined {\n  return items.find(item => item.id === id);\n}\n\n\u002F\u002F ✅ CORRECT - Generic with default\ntype ApiResponse\u003CT = unknown> = {\n  data: T;\n  meta: { timestamp: string };\n};\n```\n\nAn unconstrained `\u003CT>` is reserved to structural containers such as `ApiResponse` above; a domain function's generic always carries a semantic constraint (`extends { id: string }`, `extends DomainError`, …).\n\nCost: an unconstrained `\u003CT>` on a domain function accepts any shape at all, so a typo'd field name on the call site fails at runtime instead of at the call.\n\n## Nullability Patterns\n\n```typescript\n\u002F\u002F ✅ Explicit return types for nullable\nfunction findTenant(id: string): Tenant | null { ... }\n\n\u002F\u002F ✅ Non-null assertion only when truly guaranteed\nconst element = document.getElementById('root')!; \u002F\u002F Only in entry points\n\n\u002F\u002F ❌ AVOID - Non-null assertion to silence compiler\nconst tenant = findTenant(id)!; \u002F\u002F Use narrowing instead\n\n\u002F\u002F ✅ CORRECT - Narrowing\nconst tenant = findTenant(id);\n\nif (tenant === null) {\n  throw new NotFoundException('Tenant not found');\n}\n\n\u002F\u002F tenant is now Tenant (narrowed)\n```\n\nAbsence in a domain type is written as an explicit | null; ? is reserved for external payload shapes and partial update commands.\n\nThe non-null assertion `!` is reserved to a framework entry point — application bootstrap, DI container resolution — never to a domain handler or service.\n\n## Command and Query Handler Typing\n\nOn the Command side, publish a named function-type alias after the handler's file and annotate the factory with it; on the Query side, let it infer.\n\nThe exported handler type alias lives in the handler's own file, never centralized in a shared `types.ts` barrel.\n\n```typescript\n\u002F\u002F createReceipt.ts\nexport type CreateReceiptHandler = (command: CreateReceiptCommand) => AsyncResult\u003CReceipt, DomainError>;\n\nconst createReceipt: CreateReceiptHandler = (command) => { ... };\n\n\u002F\u002F findReceiptById.ts — Query, no alias, inferred return type\nconst findReceiptById = (query: FindReceiptByIdQuery) => { ... };\n```\n\n## Quick Reference\n\n| Rule | Convention |\n|------|-----------|\n| Strict mode | `strict: true`, always |\n| No `any` | Use `unknown` + narrowing |\n| No `typeof import(...)` | Use `import type` at top of file |\n| No `enum` | Use `as const` + type union |\n| type vs interface | `type` by default, `interface` for merging\u002Fextends |\n| Exclusive states | Discriminated unions |\n| Value validation | `satisfies` to preserve literal types |\n| ID safety | `Brand\u003CT, B>`, minted once in the kernel, never asserted in the domain |\n| Subsets | `Pick`, `Omit`, `Partial`, `Required` |\n| Nullability | Explicit `| null`, narrowing over `!` |\n",{"name":5,"description":7},"main","479b264ec17cc5fafbf36287a1087472d3a386d3","plugins\u002Ftypescript\u002Fskills\u002Fts-conventions",2,"https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace","https:\u002F\u002Fgithub.com\u002FFabienSalles","https:\u002F\u002Ffabiensalles.com","2026-10-13 04:33:22",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add FabienSalles\u002Fclaude-marketplace --skill ts-conventions",{"tool":54,"command":55},"bunx","bunx skills add FabienSalles\u002Fclaude-marketplace --skill ts-conventions",{"tool":57,"command":58},"pnpm","pnpm dlx skills add FabienSalles\u002Fclaude-marketplace --skill ts-conventions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-conventions\u002FSKILL.md",true,[62,68,72],{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"code-quality-reviewer-prompt.md","REFERENCE","参考文档",1115,"https:\u002F\u002Fgithub.com\u002FHerxinsasa\u002FSkills-Collector\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fsubagent-driven-development\u002Fcode-quality-reviewer-prompt.md",{"path":69,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":70,"sourceHtmlUrl":71},"implementer-prompt.md",4258,"https:\u002F\u002Fgithub.com\u002FHerxinsasa\u002FSkills-Collector\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fsubagent-driven-development\u002Fimplementer-prompt.md",{"path":73,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":74,"sourceHtmlUrl":75},"spec-reviewer-prompt.md",1999,"https:\u002F\u002Fgithub.com\u002FHerxinsasa\u002FSkills-Collector\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fsubagent-driven-development\u002Fspec-reviewer-prompt.md",[77,99,115,132,152,169],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":35},"01M6DW2YS1MGF65JNS1QQ15QHS","vitest-test-conventions","ACTIVATE when writing Vitest tests, creating test files, using vi.fn()\u002Fvi.mock()\u002Fvi.spyOn(), or test factories. ACTIVATE for 'Vitest', 'it.each', 'NestJS testing module', 'supertest', 'vi.fn', 'vi.mock', 'spyOn'. Provides Vitest\u002FNestJS-specific testing patterns; cross-language testing principles (DAMP, AAA, spy over mock, what NOT to test) live in craft:testing-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), TDD workflow\u002Fiterations (see vitest:vitest-tdd-workflow), PHP\u002FPHPUnit tests (see phpunit:php-test-conventions).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions\u002FSKILL.md",[],[84,85,19,86,87,21,88,89,90,91,28,92,93,29,30,94,95,96,97,98],"test","vitest","vitest test conventions","testing","tdd","workflow","file","testing patterns","files","nestjs","project","tests","module","fn","testing principles",{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":35},"01M6DW2VFE6NPFCGQKQ68P1MVZ","vitest-tdd-workflow","ACTIVATE when building new features, endpoints, or user stories using TDD with Vitest in a TypeScript\u002FNestJS context. ACTIVATE for '\u002Ffeature-tdd-dev', 'TDD', 'red-green-refactor' in TS context. Provides Vitest\u002FNestJS-specific TDD examples and commands; cross-language TDD workflow (cross-layer iterations, RED-GREEN-REFACTOR, working app, bug-fix-first-test, mocks-hiding-bugs) lives in craft:tdd-workflow-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), test writing conventions (see vitest:vitest-test-conventions), PHP TDD (see phpunit:php-tdd-workflow).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-tdd-workflow\u002FSKILL.md",[],[88,89,106,85,107,21,108,90,109,110,28,111,92,29,30,112,94,95,113,114],"tdd workflow","vitest tdd workflow","dev","examples","fix","red-green-refactor","green","feature","app",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":35},"01M6DW2RGMQE10D8C5Z5MA2RMY","ts-refactoring","ACTIVATE when refactoring TypeScript code. ACTIVATE for 'refactor', 'extract', 'redesign', 'simplify', or 'clean up' in a TypeScript \u002F Node \u002F NestJS context. This skill provides TS-specific examples for the cross-language refactoring rules defined in craft:refactoring-principles. DO NOT use for: writing new features from scratch, general OOP patterns (see ts-oop).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-refactoring\u002FSKILL.md",[],[122,123,21,22,24,109,124,125,27,126,127,28,128,129,130,93,131,29,30,31],"refactoring","ts refactoring","refactor","simplify","node","redesign","up","general","clean","craft",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":35},"01M6DW2MHYXNBBVYEGB058Y48J","ts-ports-adapters","ACTIVATE when a TypeScript codebase with no dependency-injection container has to declare a port and wire its adapter — a repository, a clock, an id generator, an event dispatcher the domain depends on. ACTIVATE for 'port', 'adapter', 'SPI', 'dependency inversion' or 'composition root' in a codebase that wires its dependencies by hand. Covers: the port as a type of functions in the domain layer, the adapter as an object literal annotated with it, the handler that takes its dependencies first and its data second, the composition root in the infrastructure layer, and the in-memory stub that substitutes for the adapter in a unit test. DO NOT use for: NestJS, or any container-based DI with decorators and tokens (see nest-ddd-conventions), aggregate operations and smart constructors (see ddd-ts-fp), the Result type itself (see ts-functional).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-ports-adapters\u002FSKILL.md",[],[139,140,141,84,142,143,28,144,145,93,146,29,30,147,148,149,150,33,34,151],"ports","ts ports adapters","memory","ddd","Composition","container","functions","Literal","dependency-injection","domain","tokens","as","adapter",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":158,"publishedAt":35},"01M6DW2GRXZFYT05HEDB26C9B8","ts-oop","ACTIVATE when designing TypeScript classes, and the value objects or collections modelled as classes, or when the user asks about object design, encapsulation, Tell Don't Ask, or Symbol.iterator. Provides TS-specific examples for the cross-language OOP rules defined in craft:oop-principles, plus TS-specific patterns (Symbol.iterator, branded types for primitive identifiers). DO NOT use for: a value object or an aggregate modelled as an immutable record rather than a class (see ddd-ts-fp), refactoring methodology (see ts-refactoring).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-oop\u002FSKILL.md",[],[159,160,161,22,142,109,162,163,122,27,164,28,165,131,29,30,166,167,168,150],"oop","ts oop","design","methodology","immutable","ask","refactoring methodology","objects","record","collections",{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":175,"publishedAt":35},"01M6DW2D26XG5MJMTP9MSE43S2","ts-layer-boundaries","ACTIVATE when wiring a Worker entry point, a Router, a controller, or a domain event consumer in a TypeScript CQRS codebase, or when deciding where a port belongs. ACTIVATE for 'composition root', 'layer boundary', 'ESLint zones', 'domain must not import infrastructure'. Covers: the *Worker.ts composition root, the curried consumer, Router wiring of command endpoints, the five-gesture controller, the domain-to-infrastructure import boundary enforced by ESLint, infrastructure-only ports, in-memory doubles for every port, the read-can-reach-write asymmetry, and read endpoints going through a domain handler. DO NOT use for: the port's own shape and adapter binding (see ts-ports-adapters), the Result type (see ts-functional), domain event structure (see ts-ddd-events).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-layer-boundaries\u002FSKILL.md",[],[176,141,142,177,178,143,139,28,179,180,181,29,30,182,148,183,184,33,151,185],"ts layer boundaries","controller","boundary","router","only","endpoints","structure","cqrs","worker","import"]