migrate-to-shoehorn

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

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/Kunj-Sharma03/agent-contextify --skill migrate-to-shoehorn-kunj-sharma03
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/Kunj-Sharma03/agent-contextify/tree/main/skills-main/skills/misc/migrate-to-shoehorn
Command: npx skills add https://github.com/Kunj-Sharma03/agent-contextify --skill migrate-to-shoehorn-kunj-sharma03

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 is unsafe, verbose, and requires manually specifying target types. This Skill migrates those assertions to @total-typescript/shoehorn, letting you pass partial test data while keeping type safety. ## Core Features & Use Cases - Assertion Replacement: Converts as Type into fromPartial() and as unknown as Type into fromAny() with correct imports. - Partial Test Data: Lets you supply only the properties a test cares about instead of faking entire large objects. - Use Case: A test for getUser only needs body.id from a 20-property Request type. Instead of faking every property or writing { body: { id: "123" } } as Request, the Skill rewrites it to getUser(fromPartial({ body: { id: "123" } })) and verifies with a type check. ## Quick Start Ask the assistant to find all as assertions in my test files and migrate them to @total-typescript/shoehorn.

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(). Add imports from @total-typescript/shoehorn, then run your type checker to verify the migration.

What is @total-typescript/shoehorn used for?

Shoehorn lets you pass partial data in tests while keeping TypeScript happy, replacing unsafe `as` assertions. It provides fromPartial() for partial data, fromAny() for intentionally wrong data, and fromExact() for full objects.

When should I use fromPartial vs fromAny in shoehorn?

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

Can I use shoehorn in production code?

No, shoehorn is for test code only and should never be used in production code. It exists to simplify mocking partial data in tests, not to bypass type safety in application logic.

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

Run grep -r " as [A-Z]" with --include="*.test.ts" and --include="*.spec.ts" to locate assertions in test files. Then migrate each match to the appropriate shoehorn function and run a type check.