migrate-to-shoehorn

Migrate TypeScript test files from `as` type assertions to @total-typescript/shoehorn partial data helpers.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Fatih0234/mattpocock-skills-pi --skill migrate-to-shoehorn-fatih0234
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/Fatih0234/mattpocock-skills-pi/tree/main/skills/misc/migrate-to-shoehorn
Command: npx skills add https://github.com/Fatih0234/mattpocock-skills-pi --skill migrate-to-shoehorn-fatih0234

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @total-typescript/shoehorn.

What problem does it solve? TypeScript tests often rely on as type assertions to fake large objects, which bypasses type safety, requires manually specifying target types, and forces awkward double-assertions (as unknown as Type) for intentionally wrong data. ## Core Features & Use Cases - Assertion Replacement: Converts as Type assertions to fromPartial() and as unknown as Type to fromAny() from @total-typescript/shoehorn. - Partial Test Data: Lets tests pass only the properties they care about while keeping TypeScript satisfied, even for objects with dozens of fields. - Use Case: A test suite fakes an entire Request object with 20+ properties just to check body.id. This Skill installs shoehorn, finds all as assertions in test files, and rewrites them so each test only declares the data it actually uses. ## Quick Start Ask the assistant to migrate the as type assertions in your test files to @total-typescript/shoehorn using fromPartial and fromAny.

Frequently Asked Questions about migrate-to-shoehorn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace `as` type assertions in TypeScript tests?▼

Install @total-typescript/shoehorn and replace `as Type` with `fromPartial()` and `as unknown as Type` with `fromAny()`. Find affected tests by grepping for ` as [A-Z]` in .test.ts and .spec.ts files, then run the type checker to verify.

What is the difference between fromPartial, fromAny, and fromExact in shoehorn?▼

fromPartial() accepts partial data that still type-checks, fromAny() accepts intentionally wrong data while keeping autocomplete, and fromExact() forces the full object so you can swap it with fromPartial later.

Can I use shoehorn in production code?▼

No. Shoehorn is intended for test code only, where passing partial or intentionally wrong data is a legitimate testing need. It should never be used in production code paths.

How do I pass intentionally wrong data in a TypeScript test without double assertions?▼

Use fromAny() from @total-typescript/shoehorn instead of `as unknown as Type`. It accepts data of the wrong shape for error testing while preserving autocomplete in your editor.

Why are `as` assertions a problem in TypeScript tests?▼

They bypass type safety, require manually specifying the target type, and need double assertions for intentionally wrong data. They also force you to fake every property of large objects even when a test only uses one or two.