Install any skill in seconds. Free to start, no credit card required.
Get Started Free →處理 TypeScript 類型系統無法實現的代碼模式。當遇到受限於 TypeScript 類型系統而無法實現的功能時,保留原始實作為註解並提供雙語說明。適用於:(1) 需要保留無法實現的類型定義時,(2) 處理 TypeScript 類型系統限制,(3) 為未來可能的實現預留參考。
.claude/skills/bluelovers-typescript-unimplemented-handler/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 22% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 29% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 64% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 144% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 163% | 0% |
本技能指導如何在 TypeScript 開發中處理因類型系統限制而無法實現的代碼,確保代码可维护性和未來擴展性。
當遇到 TypeScript 類型系統無法實現的功能時,必須保留原始實現作為參考。這不是簡單地刪除代碼,而是將其轉化為有意義的文檔。
typescript// ❌ 不正確:直接刪除無法實現的代碼 // 這會喪失重要的技術上下文 // ✅ 正確:保留原始實現為註解 // 原始實現:TypeScript 無法在編譯時實現動態類型推斷 // Original implementation: TypeScript cannot implement dynamic type inference at compile time /** * 類型安全的配置驗證器 * Type-safe configuration validator * * TODO: [TypeScript Limitation] 無法實現完整的運行時類型驗證 * 原因:TypeScript 類型在編譯後會被移除,無法在運行時獲取類型資訊 * 參考價值:了解類型系統的靜態特性 vs 運行時動態特性 * 替代方案:使用 run-time type guard 或 zod/joi 等運行時驗證庫 * * Original implementation (無法實現 / Not achievable): * ```typescript * type ExtractRuntimeType<T> = T extends infer U ? U : never; * // 嘗試在運行時獲取類型資訊 - 失敗 * ``` */ type IConfigValidator<T> = { validate: (value: unknown) => value is T; };
所有無法實現的代碼都必須包含中文和英文說明,確保不同背景的開發者都能理解。
typescript/** * 類型級別的遞迴深度計算 * Type-level recursive depth calculation * * 原始實現 (不可行 / Not feasible): * ```typescript * type DeepNest<T, Depth extends number> = ... * // 嘗試實現任意深度遞迴 - 達到 TypeScript 遞迴深度限制 * ``` * * 限制原因 / Limitation reason: * TypeScript 對遞迴類型有深度限制(約 50-100 層),無法實現真正的無限深度類型 * TypeScript has a recursion depth limit for types (approx 50-100 levels), * making true infinite depth types impossible */
每個無法實現的類型都必須有清晰的 TODO 標記,說明:
typescript// TODO: [TS-001] TypeScript 類型系統限制 // TODO: [TS-001] TypeScript type system limitation // // 無法實現:/ Cannot implement: // - 運行時類型反射 / Runtime type reflection // - 動態類型生成 / Dynamic type generation // // 替代方案:/ Alternative solutions: // - 使用 class-transformer 或 zod 進行運行時驗證 // - Use class-transformer or zod for runtime validation // // 未來可能:/ Future possibility: // - TypeScript 5.x 引入了更多類型運算功能 // - TypeScript 5.x introduces more type manipulation features
遇到類型錯誤
│
▼
這是 TypeScript 類型系統限制嗎?
│
├─ 是 → 進入無法實現處理流程
│
└─ 否 → 嘗試修復或尋找替代類型設計| 限制類型 | 範例 | 處理方式 | |---------|------|---------| | 運行時反射 | typeof instance 在類型上下文 | 使用 class-transformer | | 遞迴深度 | 深層嵌套類型 | 設定合理的深度上限 | | 條件類型複雜度 | 過於複雜的 infer 推斷 | 簡化或拆分類型 | | 動態類型 | 根據運行時輸入生成類型 | 使用泛型或運行時驗證 |
typescript/** * [無法實現的類型定義] * [Unimplementable type definition] * * TODO: [TS-XXX] 具體限制描述 * * 原始代碼: * ```typescript * // 這裡是原本嘗試實現但失敗的代碼 * ``` * * 限制原因: * - 中文說明 / English explanation * * 參考價值: * - 學習價值:了解 TypeScript 類型系統的限制 * - 未來實現:當 TypeScript 版本更新時可能支援 * - 替代方案:可以基於這些邏輯設計運行時解決方案 */
typescript// ❌ 無法實現 / Cannot implement /** * 嘗試從實例獲取運行時類型 * Attempt to get runtime type from instance * * TODO: [TS-Reflection-001] * TypeScript 類型在編譯後被完全擦除,無法在運行時獲取類型資訊 * TypeScript types are completely erased after compilation, * making runtime type information inaccessible * * 原始實現: * ```typescript * type InstanceType<T> = T extends new (...args: any) => infer R ? R : any; * // 問題:無法區分實例的具體類型成員 * ``` * * 替代方案: * - 使用 zod/joi/ Yup 等運行時驗證庫 * - 使用 class-transformer 的 class-transformer * - 為每個類型手動定義 runtime type guard */
typescript// ❌ 無法實現 / Cannot implement /** * 根據運行時值動態推斷類型 * Dynamically infer type based on runtime value * * TODO: [TS-Conditional-001] * TypeScript 條件類型只能在編譯時求值,無法根據運行時數據動態生成類型 * TypeScript conditional types can only be evaluated at compile time, * cannot dynamically generate types based on runtime data * * 原始實現: * ```typescript * type DynamicType<T> = T extends string * ? StringProcessor<T> * : T extends number * ? NumberProcessor<T> * : UnknownProcessor; * // 問題:無法根據運行時的實際值類型來選擇類型 * ``` */
typescript// ❌ 無法實現 / Cannot implement /** * 任意深度的嵌套類型 * Arbitrarily deep nested types * * TODO: [TS-Recursion-001] * TypeScript 對遞迴類型有深度限制(約 50-100 層取決於複雜度) * TypeScript has depth limits for recursive types * (approx 50-100 levels depending on complexity) * * 原始實現: * ```typescript * type DeepNest<T, N extends number> = * N extends 0 ? T : DeepNest<{ [K in keyof T]: DeepNest<T[K], [-1] extends [N] ? never : N] }, [-1] extends [N] ? never : N>; * // 問題:達到最大遞迴深度時會出現錯誤 * ``` * * 替代方案: * - 設定合理的最大深度(如 10 層) * - 使用迭代而非遞迴 * - 使用特定的工具類型(如 DeepPartial)而非通用實現 */
本技能包含以下內容:
當遇到以下情況時,載入相關參考文檔:
詳見:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | fail→pass | 15,676 | 8,968 | -43% | 1 | 1 | 0% | 2,805 | 3,434 | +22% | 0 | 0 | — |
case-01 | fail→pass | 15,738 | 9,794 | -38% | 1 | 1 | 0% | 2,928 | 3,781 | +29% | 0 | 0 | — |
case-02 | fail→pass | 12,312 | 9,764 | -21% | 1 | 1 | 0% | 2,279 | 3,728 | +64% | 0 | 0 | — |
case-03 | fail→pass | 9,421 | 10,021 | +6% | 1 | 1 | 0% | 1,550 | 3,777 | +144% | 0 | 0 | — |
case-04 | pass→pass | 7,340 | 6,318 | -14% | 1 | 1 | 0% | 1,340 | 3,184 | +138% | 0 | 0 | — |
case-05 | pass→pass | 3,090 | 6,118 | +98% | 1 | 1 | 0% | 549 | 3,045 | +455% | 0 | 0 | — |
case-06 | pass→pass | 3,583 | 5,628 | +57% | 1 | 1 | 0% | 656 | 2,856 | +335% | 0 | 0 | — |
case-07 | fail→pass | 7,708 | 8,895 | +15% | 1 | 1 | 0% | 1,356 | 3,569 | +163% | 0 | 0 | — |
case-09 | fail→pass | 17,062 | 12,850 | -25% | 1 | 1 | 0% | 2,565 | 4,310 | +68% | 0 | 0 | — |
case-10 | fail→pass | 15,300 | 9,971 | -35% | 1 | 1 | 0% | 2,452 | 3,713 | +51% | 0 | 0 | — |
case-11 | fail→pass | 8,163 | 6,412 | -21% | 1 | 1 | 0% | 1,407 | 3,047 | +117% | 0 | 0 | — |
case-12 | fail→pass | 6,010 | 6,255 | +4% | 1 | 1 | 0% | 1,132 | 3,131 | +177% | 0 | 0 | — |
case-13 | fail→pass | 11,520 | 9,939 | -14% | 1 | 1 | 0% | 2,026 | 3,693 | +82% | 0 | 0 | — |
case-14 | fail→pass | 12,814 | 8,157 | -36% | 1 | 1 | 0% | 2,322 | 3,471 | +49% | 0 | 0 | — |
case-15 | fail→pass | 12,606 | 7,420 | -41% | 1 | 1 | 0% | 2,200 | 3,363 | +53% | 0 | 0 | — |
case-16 | fail→pass | 15,779 | 10,084 | -36% | 1 | 1 | 0% | 2,854 | 3,808 | +33% | 0 | 0 | — |
case-17 | fail→pass | 13,296 | 11,628 | -13% | 1 | 1 | 0% | 2,415 | 4,118 | +71% | 0 | 0 | — |
case-18 | fail→pass | 17,653 | 12,996 | -26% | 1 | 1 | 0% | 2,839 | 4,195 | +48% | 0 | 0 | — |
case-19 | fail→pass | 7,883 | 9,261 | +17% | 1 | 1 | 0% | 1,379 | 3,796 | +175% | 0 | 0 | — |
case-20 | fail→pass | 12,987 | 8,910 | -31% | 1 | 1 | 0% | 2,314 | 3,478 | +50% | 0 | 0 | — |
case-21 | fail→pass | 13,206 | 12,675 | -4% | 1 | 1 | 0% | 2,453 | 4,273 | +74% | 0 | 0 | — |
case-22 | fail→pass | 3,279 | 9,798 | +199% | 1 | 1 | 0% | 585 | 3,725 | +537% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +86 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.