migrate-to-shoehorn

Migrate TypeScript test files from `as` assertions to @total-typescript/shoehorn helpers.

20|2|Updated May 16, 2026
One-click install
npx skills add https://github.com/reddb-io/red-skills --skill migrate-to-shoehorn-reddb-io
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: migrate-to-shoehorn
Source: https://github.com/reddb-io/red-skills/tree/main/plugins/dev/skills/misc/migrate-to-shoehorn
Command: npx skills add https://github.com/reddb-io/red-skills --skill migrate-to-shoehorn-reddb-io

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @total-typescript/shoehorn.

What problem does it solve? TypeScript tests often rely on as type assertions or hand-faked objects to satisfy the compiler, which is brittle, verbose, and hides type errors. This Skill replaces those assertions with fromPartial() and fromAny() from @total-typescript/shoehorn so tests pass partial or intentionally wrong data while keeping type safety. ## Core Features & Use Cases - Assertion Detection: Finds as Type and as unknown as Type patterns across test files using grep-based search. - Pattern-Based Migration: Converts as Type to fromPartial() and as unknown as Type to fromAny(), adding the correct imports. - Use Case: A test suite fakes an entire Express Request object with 20+ properties just to test one field. After migration, the test passes only fromPartial({ body: { id: "123" } }) and TypeScript still type-checks. ## Quick Start Ask the assistant to migrate the as type assertions in your test files to @total-typescript/shoehorn's fromPartial and fromAny helpers.

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 `as` type assertions in TypeScript tests?▼

Replace `as Type` with fromPartial() and `as unknown as Type` with fromAny() from @total-typescript/shoehorn. Find affected tests with grep for ` as [A-Z]` in *.test.ts and *.spec.ts files, then run a type check to verify.

What is the difference between fromPartial and fromAny in shoehorn?▼

fromPartial() accepts partial data that still type-checks against the target type, ideal for large objects where only some properties matter. fromAny() accepts intentionally wrong data while keeping autocomplete, replacing double-as casts.

Can I use @total-typescript/shoehorn in production code?▼

No, shoehorn is intended for test code only. It bypasses normal type checking to let tests pass partial or incorrect data, which would hide real type errors in production paths.

How do I pass intentionally wrong types in a TypeScript test?▼

Use fromAny() from @total-typescript/shoehorn instead of `as unknown as Type`. It lets you pass wrong-typed data for error testing while preserving autocomplete on the value you provide.

How do I install @total-typescript/shoehorn?▼

Install it with npm using `npm i @total-typescript/shoehorn`, then import fromPartial or fromAny from the package in your test files. No additional configuration is required.