migrate-to-shoehorn

Migrates TypeScript test files from `as` type assertions to @total-typescript/shoehorn partial mocks.

2|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/NAMEWTA/learning-open-code --skill migrate-to-shoehorn-namewta
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/NAMEWTA/learning-open-code/tree/main/translator/open-ai-skills/matt-pocock-skills/skills/misc/migrate-to-shoehorn
Command: npx skills add https://github.com/NAMEWTA/learning-open-code --skill migrate-to-shoehorn-namewta

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 requires manually specifying target types, faking every property, and using awkward double assertions like as unknown as Type for intentionally wrong data. This Skill replaces those assertions with type-safe partial mocks from @total-typescript/shoehorn. ## Core Features & Use Cases - Partial test data: Use fromPartial() to pass only the properties a test cares about while keeping TypeScript satisfied. - Intentionally wrong data: Use fromAny() to replace as unknown as Type when testing error paths with invalid data, while retaining autocomplete. - Guided migration workflow: Locate as assertions in test files via grep, convert each pattern, add imports, and verify with the type checker. - Use Case: A test only needs body.id from a Request type with 20+ properties. Instead of faking the entire object, wrap { body: { id: "123" } } in fromPartial() and pass it directly. ## 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 wrap the partial object in fromPartial() instead of casting with `as Type`. For intentionally wrong data previously written as `as unknown as Type`, use fromAny() instead.

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

fromPartial() accepts partial data that still passes type checking. fromAny() accepts deliberately incorrect data while keeping autocomplete. fromExact() enforces a complete object and can later be swapped with fromPartial.

Can I use shoehorn in production code?▼

No. Shoehorn is intended only for test code, where passing partial or fake data is acceptable. It should never be used in production code paths.

How do I find `as` assertions in my test files?▼

Run a grep search such as `grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"` to locate type assertions in test files, then convert each match to the appropriate shoehorn helper.

Why is `as unknown as Type` a problem in tests?▼

The double assertion bypasses type safety entirely and is required whenever you pass deliberately wrong data. fromAny() expresses the same intent explicitly while preserving autocomplete for the target type.