migrate-to-shoehorn

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

1|Updated Jul 23, 2026
One-click install
npx skills add https://github.com/sanjanb/my-agent-harness --skill migrate-to-shoehorn-sanjanb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/sanjanb/my-agent-harness/tree/main/skills/mp-migrate-to-shoehorn
Command: npx skills add https://github.com/sanjanb/my-agent-harness --skill migrate-to-shoehorn-sanjanb

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 mocks from @total-typescript/shoehorn. ## Core Features & Use Cases - Assertion Migration: Converts as Type assertions to fromPartial() and as unknown as Type to fromAny() in test files. - Partial Test Data: Lets you pass only the properties a test cares about while keeping TypeScript satisfied, even for objects with dozens of fields. - Guided Workflow: Provides a checklist covering installation, finding assertions via grep, replacing patterns, adding imports, and verifying with a type check. - Use Case: A test for getUser only needs body.id, but the Request type has 20+ properties. Instead of faking every field or using as Request, migrate to fromPartial({ body: { id: "123" } }) for a type-safe partial. ## Quick Start Ask the agent 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` assertions with fromPartial() from @total-typescript/shoehorn, which accepts partial data while keeping TypeScript satisfied. For intentionally wrong data written as `as unknown as Type`, use fromAny() instead, then run a type check to verify.

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 that still type-checks, fromAny() for intentionally wrong data, and fromExact() to force a full object.

When should I use fromPartial vs fromAny in shoehorn?

Use fromPartial() when passing partial data that should still type-check against the target type. Use fromAny() when deliberately passing wrong data for error testing, since it keeps autocomplete while bypassing type constraints.

Can I use shoehorn in production code?

No, shoehorn is intended for test code only. The migration guidance explicitly warns against using it in production code, since partial mocks bypass the type guarantees production code relies on.

How do I find `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 function and add the import.