migrate-to-shoehorn

Refactor 'as' assertions in TypeScript test files to fromPartial() and fromAny().

Updated Jun 12, 2026
One-click install
npx skills add https://github.com/flowel/AiSkills --skill migrate-to-shoehorn-flowel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/flowel/AiSkills/tree/main/skills/codex/migrate-to-shoehorn
Command: npx skills add https://github.com/flowel/AiSkills --skill migrate-to-shoehorn-flowel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @total-typescript/shoehorn, and includes scripts (resource) components.

What problem does it solve?

This Skill addresses the issue of 'as' assertions in TypeScript tests, providing a safer and more maintainable way to handle type assertions without the need for manual type specification.

Core Features & Use Cases

  • Refactoring 'as' Assertions: Converts 'as' assertions to type-safe alternatives using @total-typescript/shoehorn.
  • Partial Data Handling: Allows passing partial data in tests while maintaining TypeScript type safety.
  • Use Case: Ideal for developers who want to refactor legacy TypeScript tests to use more robust type assertions without breaking the tests.

Quick Start

Run the 'migrate-to-shoehorn' skill to automatically refactor 'as' assertions in your TypeScript test files.

Frequently Asked Questions about migrate-to-shoehorn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely refactor 'as' assertions in TypeScript tests?

You can safely refactor 'as' assertions in TypeScript tests by replacing them with 'fromPartial()' and 'fromAny()' alternatives. This approach maintains type safety while allowing partial test data handling.

Why should I replace 'as' assertions with shoehorn in my test files?

You should replace 'as' assertions with shoehorn to enforce strict type checking in automated testing environments. Using 'fromPartial()' prevents silent type errors by validating partial data against expected TypeScript types.

Do I need the @total-typescript/shoehorn package to refactor type assertions?

Yes, you need the @total-typescript/shoehorn package installed. This Skill directly refactors existing 'as' assertions into the 'fromPartial()' and 'fromAny()' utility functions provided by that specific dependency.

Can I pass partial mock data to TypeScript tests without breaking type safety?

Yes, you can pass partial mock data without breaking type safety by using 'fromPartial()'. This utility allows you to supply only the necessary test properties while ensuring the object remains fully type-checked against the target interface.

What is the best way to migrate legacy TypeScript tests to use type-safe assertions?

The best way to migrate legacy TypeScript tests to type-safe assertions is running an automated refactoring script. This process converts unsafe 'as' type casts into shoehorn's 'fromPartial()' and 'fromAny()' equivalents without breaking existing test logic.