
from mattpocock-skills190
Practical guide to replace `as` type assertions in TypeScript tests with @total-typescript/shoehorn helpers (fromPartial, fromAny) to make tests type-safe and c
This skill explains how to migrate test code that uses unsafe as assertions to @total-typescript/shoehorn helpers (fromPartial, fromAny, fromExact). It provides patterns for converting large fake objects and unsafe double-as casts into concise, type-safe test fixtures that keep TypeScript happy without verbose boilerplate.
Use when maintaining TypeScript test suites that currently rely on as Type or as unknown as Type to coerce values in tests — common during refactors or when creating lightweight fixtures for unit tests. It is explicitly for test code; not recommended for production runtime code.
as Type and as unknown as Type to fromPartial()/fromAny(), and a recommended workflow (grep to find assertions, replace, run type checks).Inferred: developer assistants and TypeScript-focused code helpers (Copilot-like models, code-aware agents).
A focused migration guide for replacing TypeScript `as` type assertions with @total-typescript/shoehorn helpers in test files. No bundled scripts — purely instructional. Clear before/after patterns and a useful function comparison table. Niche but practical for teams adopting shoehorn.
Clean, straightforward skill. No security concerns. Narrow audience limits usefulness but does its job well.