[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FEKP4YC31B3QHGJVHR3ZFS":3,"skill-same:01M6FEKP4YC31B3QHGJVHR3ZFS":53},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":26,"linkOnly":27,"markdownContent":28,"markdownBody":28,"frontMatter":29,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M6FEKP4YC31B3QHGJVHR3ZFS","typescript-refactor",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fpproenca\u002Fdot-skills\u002Ftypescript-refactor\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000007","代码审查","SCENARIO","使用场景",[23,24,25],"typescript","refactor","typescript refactor","2026-11-10 10:12:30",false,"# TypeScript Refactor Best Practices\n\nComprehensive TypeScript refactoring and modernization guide designed for AI agents and LLMs. Contains 43 rules across 8 categories, prioritized by impact to guide automated refactoring, code review, and code generation.\n\n## When to Apply\n\nReference these guidelines when:\n- Refactoring TypeScript code for type safety and maintainability\n- Designing type architectures (discriminated unions, branded types, generics)\n- Narrowing types to eliminate unsafe `as` casts\n- Adopting modern TypeScript 4.x-5.x features (`satisfies`, `using`, const type parameters)\n- Optimizing compiler performance in large codebases\n- Implementing type-safe error handling patterns\n- Reviewing code for TypeScript quirks and pitfalls\n\n## Rule Categories by Priority\n\n| Priority | Category | Impact | Prefix |\n|----------|----------|--------|--------|\n| 1 | Type Architecture | CRITICAL | `arch-` |\n| 2 | Type Narrowing & Guards | CRITICAL | `narrow-` |\n| 3 | Modern TypeScript | HIGH | `modern-` |\n| 4 | Generic Patterns | HIGH | `generic-` |\n| 5 | Compiler Performance | MEDIUM-HIGH | `compile-` |\n| 6 | Error Safety | MEDIUM | `error-` |\n| 7 | Runtime Patterns | MEDIUM | `perf-` |\n| 8 | Quirks & Pitfalls | LOW-MEDIUM | `quirk-` |\n\n## Quick Reference\n\n### 1. Type Architecture (CRITICAL)\n\n- [`arch-discriminated-unions`](references\u002Farch-discriminated-unions.md) — Use discriminated unions over string enums for exhaustive pattern matching\n- [`arch-branded-types`](references\u002Farch-branded-types.md) — Use branded types for domain identifiers to prevent value mix-ups\n- [`arch-satisfies-over-annotation`](references\u002Farch-satisfies-over-annotation.md) — Use `satisfies` for config objects to preserve literal types\n- [`arch-interfaces-over-intersections`](references\u002Farch-interfaces-over-intersections.md) — Extend interfaces instead of intersecting types for better error messages\n- [`arch-const-assertion`](references\u002Farch-const-assertion.md) — Use `as const` for immutable literal inference\n- [`arch-readonly-by-default`](references\u002Farch-readonly-by-default.md) — Default to readonly types for function parameters and return values\n- [`arch-avoid-partial-abuse`](references\u002Farch-avoid-partial-abuse.md) — Avoid `Partial\u003CT>` abuse for builder patterns\n\n### 2. Type Narrowing & Guards (CRITICAL)\n\n- [`narrow-custom-type-guards`](references\u002Fnarrow-custom-type-guards.md) — Write custom type guards instead of type assertions\n- [`narrow-assertion-functions`](references\u002Fnarrow-assertion-functions.md) — Use assertion functions for precondition checks\n- [`narrow-exhaustive-switch`](references\u002Fnarrow-exhaustive-switch.md) — Enforce exhaustive switch with `never`\n- [`narrow-in-operator`](references\u002Fnarrow-in-operator.md) — Narrow with the `in` operator for interface unions\n- [`narrow-eliminate-as-casts`](references\u002Fnarrow-eliminate-as-casts.md) — Eliminate `as` casts with proper narrowing chains\n- [`narrow-typeof-chains`](references\u002Fnarrow-typeof-chains.md) — Use `typeof` narrowing before property access\n\n### 3. Modern TypeScript (HIGH)\n\n- [`modern-using-keyword`](references\u002Fmodern-using-keyword.md) — Use the `using` keyword for resource cleanup\n- [`modern-const-type-parameters`](references\u002Fmodern-const-type-parameters.md) — Use const type parameters for literal inference\n- [`modern-template-literal-types`](references\u002Fmodern-template-literal-types.md) — Use template literal types for string patterns\n- [`modern-noinfer-utility`](references\u002Fmodern-noinfer-utility.md) — Use `NoInfer` to control type parameter inference\n- [`modern-accessor-keyword`](references\u002Fmodern-accessor-keyword.md) — Use `accessor` for auto-generated getters and setters\n- [`modern-verbatim-module-syntax`](references\u002Fmodern-verbatim-module-syntax.md) — Enable `verbatimModuleSyntax` for explicit import types\n\n### 4. Generic Patterns (HIGH)\n\n- [`generic-infer-over-annotate`](references\u002Fgeneric-infer-over-annotate.md) — Let TypeScript infer instead of explicit annotation\n- [`generic-constrain-dont-overconstrain`](references\u002Fgeneric-constrain-dont-overconstrain.md) — Constrain generics minimally\n- [`generic-avoid-distributive-surprises`](references\u002Fgeneric-avoid-distributive-surprises.md) — Control distributive conditional types\n- [`generic-mapped-type-utilities`](references\u002Fgeneric-mapped-type-utilities.md) — Build custom mapped types for repeated transformations\n- [`generic-return-type-inference`](references\u002Fgeneric-return-type-inference.md) — Preserve return type inference in generic functions\n\n### 5. Compiler Performance (MEDIUM-HIGH)\n\n- [`compile-explicit-return-types`](references\u002Fcompile-explicit-return-types.md) — Add explicit return types to exported functions\n- [`compile-avoid-deep-recursion`](references\u002Fcompile-avoid-deep-recursion.md) — Avoid deeply recursive type definitions\n- [`compile-project-references`](references\u002Fcompile-project-references.md) — Use project references for monorepo builds\n- [`compile-base-types-over-unions`](references\u002Fcompile-base-types-over-unions.md) — Use base types instead of large union types\n\n### 6. Error Safety (MEDIUM)\n\n- [`error-result-type`](references\u002Ferror-result-type.md) — Use Result types instead of thrown exceptions\n- [`error-exhaustive-error-handling`](references\u002Ferror-exhaustive-error-handling.md) — Use exhaustive checks for typed error variants\n- [`error-typed-catch`](references\u002Ferror-typed-catch.md) — Type catch clause variables as `unknown`\n- [`error-never-for-unreachable`](references\u002Ferror-never-for-unreachable.md) — Use `never` to mark unreachable code paths\n- [`error-discriminated-error-unions`](references\u002Ferror-discriminated-error-unions.md) — Model domain errors as discriminated unions\n\n### 7. Runtime Patterns (MEDIUM)\n\n- [`perf-union-literals-over-enums`](references\u002Fperf-union-literals-over-enums.md) — Use union literals instead of enums\n- [`perf-avoid-delete-operator`](references\u002Fperf-avoid-delete-operator.md) — Avoid the `delete` operator on objects\n- [`perf-object-freeze-const`](references\u002Fperf-object-freeze-const.md) — Use `Object.freeze` with `as const` for true immutability\n- [`perf-object-keys-narrowing`](references\u002Fperf-object-keys-narrowing.md) — Avoid `Object.keys` type widening\n- [`perf-map-set-over-object`](references\u002Fperf-map-set-over-object.md) — Use `Map` and `Set` over plain objects for dynamic collections\n\n### 8. Quirks & Pitfalls (LOW-MEDIUM)\n\n- [`quirk-excess-property-checks`](references\u002Fquirk-excess-property-checks.md) — Understand excess property checks on object literals\n- [`quirk-empty-object-type`](references\u002Fquirk-empty-object-type.md) — Avoid the `{}` type — it means non-nullish\n- [`quirk-type-widening-let`](references\u002Fquirk-type-widening-let.md) — Prevent type widening with `let` declarations\n- [`quirk-variance-annotations`](references\u002Fquirk-variance-annotations.md) — Use variance annotations for generic interfaces\n- [`quirk-structural-typing-escapes`](references\u002Fquirk-structural-typing-escapes.md) — Guard against structural typing escape hatches\n\n## How to Use\n\nRead individual reference files for detailed explanations and code examples:\n\n- [Section definitions](references\u002F_sections.md) — Category structure and impact levels\n- [Rule template](assets\u002Ftemplates\u002F_template.md) — Template for adding new rules\n\n## Reference Files\n\n| File | Description |\n|------|-------------|\n| [references\u002F_sections.md](references\u002F_sections.md) | Category definitions and ordering |\n| [assets\u002Ftemplates\u002F_template.md](assets\u002Ftemplates\u002F_template.md) | Template for new rules |\n| [metadata.json](metadata.json) | Version and reference information |\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fpproenca\u002Fdot-skills\u002Ftypescript-refactor",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill typescript-refactor",{"tool":45,"command":46},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill typescript-refactor",{"tool":48,"command":49},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill typescript-refactor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fpproenca\u002Fdot-skills\u002Ftypescript-refactor\u002FSKILL.md",true,[],[54,66,76,85,91,98],{"skillNo":55,"name":56,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":62,"publishedAt":26},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[59],{"categoryNo":60,"categoryName":61,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",[63,64,65],"model","model hierarchy","model hierarchy skill",{"skillNo":67,"name":68,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":72,"publishedAt":26},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[71],{"categoryNo":60,"categoryName":61,"taxonomyType":20,"taxonomyTypeDesc":21},[73,74,75],"MCP","zoom","zoom mcp",{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":26},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[82,83,84,74],"sdk","zoom apps sdk","apps",{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":26},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[87],{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":97,"publishedAt":26},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[96],{"categoryNo":60,"categoryName":61,"taxonomyType":20,"taxonomyTypeDesc":21},[93],{"skillNo":99,"name":100,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":26},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[100]]