migrate-to-shoehorn

Refactor TypeScript test files by replacing unsafe type assertions with shoehorn alternatives.

Updated Apr 8, 2026
One-click install
npx skills add https://github.com/tonomb/personal-pnl --skill migrate-to-shoehorn-tonomb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/tonomb/personal-pnl/tree/main/.agents/skills/migrate-to-shoehorn
Command: npx skills add https://github.com/tonomb/personal-pnl --skill migrate-to-shoehorn-tonomb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @total-typescript/shoehorn.

What problem does it solve?

This skill addresses the fragility and safety issues associated with using TypeScript type assertions (as) in test suites, which often lead to brittle tests and hidden runtime errors.

Core Features & Use Cases

  • Type-Safe Partial Data: Replaces unsafe as assertions with fromPartial to allow partial object definitions that satisfy TypeScript requirements.
  • Intentional Error Testing: Provides fromAny to handle cases where intentionally incorrect data is required for testing error states.
  • Use Case: When refactoring a test suite that relies heavily on casting large objects, this skill automates the migration to shoehorn to ensure tests remain type-safe while reducing boilerplate.

Quick Start

Use the migrate-to-shoehorn skill to identify all as assertions in the current test directory and replace them with the appropriate fromPartial or fromAny functions.

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 type assertions in TypeScript test files?

You can replace unsafe type assertions in TypeScript test files by using the shoehorn library, which provides type-safe alternatives like `fromPartial` for partial mock data and `fromAny` for intentional error testing.

What is the best way to refactor `as unknown as` casts in unit testing?

The best way to refactor `as unknown as` casts in unit testing is using the `@total-typescript/shoehorn` package, replacing them with `fromAny` to safely handle intentionally incorrect data required for testing error states.

Does replacing `as` assertions with shoehorn require any specific package setup?

Yes, replacing `as` assertions with shoehorn requires installing the `@total-typescript/shoehorn` package and executing grep-based search patterns to identify and update target test files containing large object mocks.

Why do brittle type assertions cause hidden runtime errors in test suites?

Brittle type assertions cause hidden runtime errors in test suites because `as` bypasses TypeScript's type checking, allowing malformed data to slip through. `shoehorn` solves this by enforcing type safety while reducing boilerplate.

When should I use `fromPartial` vs `fromAny` during a type-safety refactoring?

Use `fromPartial` during type-safety refactoring for partial object definitions satisfying TypeScript requirements, and use `fromAny` when your tests require intentionally incorrect data for testing error states.

Can I automate finding and replacing type assertions across my test directory?

Yes, you can automate finding and replacing type assertions across your test directory by executing grep-based search patterns to locate `as` syntax and migrating them to shoehorn's type-safe functions.