
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).
This skill has not been reviewed by our automated audit pipeline yet.