migrate-to-shoehorn

Migrate TypeScript test data from as assertions to shoehorn helpers.

12|Updated Dec 25, 2024
One-click install
npx skills add https://github.com/whyte25/reusables --skill migrate-to-shoehorn-whyte25
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/whyte25/reusables/tree/main/.agents/skills/migrate-to-shoehorn
Command: npx skills add https://github.com/whyte25/reusables --skill migrate-to-shoehorn-whyte25

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It eliminates brittle TypeScript test code that relies on unsafe as type assertions by replacing them with type-safe partial data builders.

Core Features & Use Cases

  • Migrate large test fixtures: Convert “fake the entire object” patterns into minimal, partial payloads that still type-check.
  • Replace as Type with fromPartial: Use fromPartial for valid partial data that should remain type-correct.
  • Replace as unknown as Type with fromAny: Use fromAny for intentionally incorrect test data while preserving developer ergonomics.
  • Use case: When tests construct large request/response objects but only a few properties matter, migrate those tests to pass only the required fields safely.

Quick Start

Ask an AI to migrate your test files by replacing as Request patterns with fromPartial for valid partial data and replacing double-as patterns with fromAny for intentionally incorrect inputs, while keeping the rest of the test logic unchanged.

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

Replace unsafe TypeScript as type assertions by mapping valid partial data casts to fromPartial and intentionally incorrect double-as casts to fromAny using @total-typescript/shoehorn. This migration preserves type safety while allowing minimal test payloads.

What is the difference between fromPartial and fromAny in TypeScript testing?

In TypeScript testing, fromPartial supplies valid partial data that remains type-correct, whereas fromAny is used for intentionally incorrect test data. Both helpers replace unsafe as type assertions to maintain type checking while improving developer ergonomics.

How do I migrate large test fixtures to only pass required properties in TypeScript?

To migrate large test fixtures to pass only required properties in TypeScript, replace full object as Type casts with fromPartial. This allows unit and integration tests to supply minimal, partial payloads that still satisfy parameter types without faking the entire object.

Do I need to install @total-typescript/shoehorn to use fromPartial and fromAny?

Yes, installing @total-typescript/shoehorn is required to use fromPartial and fromAny. These helpers replace unsafe as unknown as Type patterns, ensuring your TypeScript test data type-checks correctly after migration.

When should I use as unknown as Type in TypeScript tests?

You should replace as unknown as Type in TypeScript tests with the fromAny helper from @total-typescript/shoehorn. This approach preserves the ability to supply intentionally incorrect test data while maintaining type safety and developer ergonomics.