migrate-to-shoehorn

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

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/toderian/project_template --skill migrate-to-shoehorn-toderian
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/toderian/project_template/tree/main/plugins/agents-personal/skills/migrate-to-shoehorn
Command: npx skills add https://github.com/toderian/project_template --skill migrate-to-shoehorn-toderian

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. This Skill replaces those assertions with type-safe partial test data using @total-typescript/shoehorn. ## Core Features & Use Cases - Pattern-based migration: Converts as Type assertions to fromPartial() and as unknown as Type to fromAny(), with fromExact() available for full-object enforcement. - Guided workflow: Walks through requirement gathering, package installation, grep-based discovery of as assertions in test files, replacement, and type-check verification. - Use Case: A test needs only body.id from a 20-property Request type. Instead of faking every property or casting with as Request, the migration rewrites it as getUser(fromPartial({ body: { id: "123" } })), keeping autocomplete and type checking intact. ## 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?

Replace `as Type` with fromPartial() from @total-typescript/shoehorn, which accepts partial data while keeping type checking. For intentionally wrong data written as `as unknown as Type`, use fromAny() instead, then run your type checker to verify.

What is @total-typescript/shoehorn used for?

Shoehorn creates type-safe partial test data in TypeScript. It lets you pass only the properties a test cares about instead of faking entire large objects, while preserving autocomplete and compile-time checks. It is intended for test code only, never production code.

When should I use fromPartial vs fromAny vs fromExact?

Use fromPartial() for partial data that still type-checks, fromAny() for intentionally wrong data such as error-case testing while keeping autocomplete, and fromExact() to force a full object that you can later swap to fromPartial.

Can I use shoehorn in production code?

No. Shoehorn is designed for test code only, where partial or intentionally incorrect data is acceptable. Using it in production code would bypass TypeScript's type guarantees where real data integrity matters.

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

Run grep with a pattern like `grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"` to locate capitalized type assertions in test files. Then replace each match with the appropriate shoehorn helper and add the import.