migrate-to-shoehorn

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

Updated Jul 30, 2026
One-click install
npx skills add https://github.com/j172/bid --skill migrate-to-shoehorn-j172
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/j172/bid/tree/main/agent/skills/migrate-to-shoehorn
Command: npx skills add https://github.com/j172/bid --skill migrate-to-shoehorn-j172

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @total-typescript/shoehorn.

What problem does it solve? TypeScript tests often rely on as type assertions or as unknown as Type casts to fake large objects, which bypasses type safety and requires manually faking every property. This Skill migrates those assertions to @total-typescript/shoehorn so tests can pass partial data while keeping type checking intact. ## Core Features & Use Cases - Assertion Migration: Replaces as Type with fromPartial() and as unknown as Type with fromAny() across test files. - Partial Test Data: Lets tests supply only the properties that matter for large request or model objects without faking the rest. - Use Case: A test suite calls getUser({ body: { id: "123" } } as Request) where Request has 20+ properties. The Skill installs shoehorn, rewrites the call to getUser(fromPartial({ body: { id: "123" } })), adds the import, and verifies with a type check. ## Quick Start Migrate the as assertions in my 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` casts 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.

What is @total-typescript/shoehorn used for?

Shoehorn lets tests pass partial data while keeping TypeScript satisfied, avoiding `as` assertions. It provides fromPartial() for partial valid data, 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 still type-checks, such as faking a large Request object with only the needed properties. Use fromAny() when passing intentionally wrong data for error testing while keeping autocomplete.

Can I use shoehorn in production code?

No, shoehorn is intended for test code only. It exists to replace unsafe `as` assertions in tests with type-safe partial mocks, and should never be used in production code paths.

How do I find test files that need shoehorn migration?

Search test files for assertions with a grep pattern like `grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"`. Then replace each match with fromPartial() or fromAny() and run a type check to verify.