migrate-to-shoehorn

Replace TypeScript type assertions in tests with shoehorn helpers.

195|16|Updated Feb 18, 2025
One-click install
npx skills add https://github.com/InditexTech/weavejs --skill migrate-to-shoehorn-inditextech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/InditexTech/weavejs/tree/main/code/.agents/skills/migrate-to-shoehorn
Command: npx skills add https://github.com/InditexTech/weavejs --skill migrate-to-shoehorn-inditextech

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrate test files from risky type assertions using explicit 'as' to safer shoehorn helpers, improving type-safety and maintainability.

Core Features & Use Cases

  • Replaces 'as Type' in tests with fromPartial(...) for safer partial data.
  • Converts 'as unknown as Type' patterns to fromAny() to preserve autocomplete while ensuring type checks.
  • Provides migration guidance and minimal production risk.

Quick Start

Migrate existing tests by replacing 'as Type' with fromPartial(...) and 'as unknown as Type' with fromAny(), then add the necessary imports.

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 type assertions in TypeScript tests with safer alternatives?

To replace type assertions in TypeScript tests, migrate explicit 'as Type' expressions to shoehorn helpers like fromPartial(...) for safer partial data, or fromAny() for intentionally incorrect data, then add the required imports to ensure tests compile safely.

What is the best way to handle 'as unknown as Type' patterns in TypeScript test files?

The best way to handle 'as unknown as Type' patterns is to convert them to fromAny(), which preserves autocomplete while ensuring type checks. This migration to shoehorn helpers improves type-safety and maintainability in tests.

Do I need to install external packages to migrate tests to shoehorn?

Yes, migrating tests to shoehorn requires installing the @total-typescript/shoehorn package and adding the appropriate imports to your test files. This ensures fromPartial, fromAny, or fromExact compile correctly.

When should I use fromPartial versus fromAny for test data migration?

Use fromPartial when replacing 'as Type' for safer partial object payloads in tests. Use fromAny when converting 'as unknown as Type' patterns to preserve autocomplete while ensuring type checks for intentionally incorrect data.

Can I migrate tests that heavily use object literals and partial payloads to shoehorn?

Yes, shoehorn migration specifically applies to tests that heavily use object literals, partial payloads, or intentionally incorrect data. It replaces risky type assertions with safer helpers to improve overall type-safety.

Why does using explicit 'as' in TypeScript tests pose a maintenance risk?

Using explicit 'as' in TypeScript tests poses a maintenance risk because it bypasses type checking. Migrating to shoehorn helpers like fromPartial ensures type safety and provides minimal production risk during test data construction.