migrate-to-shoehorn

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

10|3|Updated Jul 18, 2019
One-click install
npx skills add https://github.com/tanqimin/MyFavsORM --skill migrate-to-shoehorn-tanqimin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/tanqimin/MyFavsORM/tree/main/.agents/skills/migrate-to-shoehorn
Command: npx skills add https://github.com/tanqimin/MyFavsORM --skill migrate-to-shoehorn-tanqimin

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 error-prone, 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 shoehorn helpers. ## Core Features & Use Cases - Partial test data: Replace as Type with fromPartial() so tests only specify the properties they actually need while staying type-checked. - Intentionally wrong data: Replace as unknown as Type with fromAny() for error-path testing while keeping autocomplete. - Full-object enforcement: Use fromExact() to require a complete object now and swap to fromPartial() later. - Use Case: A test for getUser only cares about body.id but the Request type has 20+ properties. Instead of faking every property or casting with as Request, call getUser(fromPartial({ body: { id: "123" } })). ## Quick Start Find all as assertions in my test files and migrate them 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 replace `as Type` with fromPartial() and `as unknown as Type` with fromAny(). Find candidates by grepping for ` as [A-Z]` in .test.ts and .spec.ts files, then run a type check to verify.

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

fromPartial() accepts partial data that still type-checks, fromAny() accepts intentionally wrong data while keeping autocomplete, and fromExact() forces a full object that you can later swap to fromPartial().

Can I use @total-typescript/shoehorn in production code?

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

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

Double assertions bypass TypeScript's type checking entirely and are awkward to write and read. fromAny() expresses the same intent—passing deliberately wrong data—while preserving autocomplete and clearer semantics.

How do I find test files that need shoehorn migration?

Run grep with the pattern ` as [A-Z]` limited to *.test.ts and *.spec.ts files. This locates type assertions in test files that are candidates for fromPartial() or fromAny() replacement.