migrate-to-shoehorn

Migrate TypeScript test assertions to shoehorn's fromPartial and fromAny.

1|Updated May 5, 2026
One-click install
npx skills add https://github.com/yashs33244/my-mac-claude --skill migrate-to-shoehorn-yashs33244
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/yashs33244/my-mac-claude/tree/main/skills/mattpocock/misc/migrate-to-shoehorn
Command: npx skills add https://github.com/yashs33244/my-mac-claude --skill migrate-to-shoehorn-yashs33244

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you remove brittle TypeScript as assertions in tests by migrating to type-safe partial data using @total-typescript/shoehorn, so your tests stay correct and maintainable.

Core Features & Use Cases

  • Migrates test data typing: Replaces as Type with fromPartial() for partial objects that should still be type-compatible.
  • Supports intentionally wrong inputs: Converts as unknown as Type patterns to fromAny() when you need to preserve autocomplete while feeding invalid data for negative/error-path tests.
  • Guides safe test-only adoption: Emphasizes that shoehorn should be used only in test code and provides a clear workflow for updating code and re-running type checks.
  • Real-world example: You have large request objects in tests where you only care about body.id, and you want to avoid faking 20+ unrelated properties just to satisfy the compiler.

Quick Start

Ask the Skill to migrate your TypeScript test files by replacing as Type assertions with fromPartial() (and as unknown as Type with fromAny()), then verify with a type check.

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 unsafe `as` assertions in TypeScript tests with type-safe partials?

To replace unsafe `as` assertions in TypeScript tests with type-safe partials, you can use the `fromPartial()` function from `@total-typescript/shoehorn` to provide only the required object fields while maintaining type compatibility.

What is the best way to test error paths in TypeScript without losing autocomplete on invalid data?

The best way to test error paths with invalid data in TypeScript is using `fromAny()` from `@total-typescript/shoehorn`, which preserves autocomplete while allowing you to feed wrong data into negative tests without breaking type checks.

How do I stop faking 20+ unrelated properties just to satisfy TypeScript compiler in unit tests?

To stop faking 20+ unrelated properties for the TypeScript compiler in unit tests, migrate your test data typing to use `fromPartial()`, which allows you to pass only the subset of fields you care about, like `body.id`, without faking the rest.

Does migrating test files to shoehorn require updating imports and re-running type checks?

Yes, migrating test files to shoehorn requires updating test code to use `fromPartial()` and `fromAny()` with the appropriate import, and then re-running type checks to confirm that your TypeScript compilation succeeds.

When should I not use shoehorn for TypeScript test migrations?

You should not use shoehorn outside of test code, as it is explicitly designed for test-only adoption to replace brittle `as Type` and `as unknown as Type` assertions with safer partial data patterns.

Can I convert `as unknown as Type` patterns to a safer alternative for negative testing?

Yes, you can convert `as unknown as Type` patterns to `fromAny()` using `@total-typescript/shoehorn`, which intentionally supports feeding invalid data for error-path tests while keeping autocomplete functional.