migrate-to-shoehorn

Solid

Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.

AI & Automation 485 stars 58 forks Updated today MIT

Install

View on GitHub

Quality Score: 91/100

Stars 20%
89
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Migrate to Shoehorn ## Why shoehorn? `shoehorn` lets you pass partial data in tests while keeping TypeScript happy. It replaces `as` assertions with type-safe alternatives. **Test code only.** Never use shoehorn in production code. Problems with `as` in tests: - Trained not to use it - Must manually specify target type - Double-as (`as unknown as Type`) for intentionally wrong data ## Install ```bash npm i @total-typescript/shoehorn ``` ## Migration patterns ### Large objects with few needed properties Before: ```ts type Request = { body: { id: string }; headers: Record<string, string>; cookies: Record<string, string>; // ...20 more properties }; it("gets user by id", () => { // Only care about body.id but must fake entire Request getUser({ body: { id: "123" }, headers: {}, cookies: {}, // ...fake all 20 properties }); }); ``` After: ```ts import { fromPartial } from "@total-typescript/shoehorn"; it("gets user by id", () => { getUser( fromPartial({ body: { id: "123" }, }), ); }); ``` ### `as Type` → `fromPartial()` Before: ```ts getUser({ body: { id: "123" } } as Request); ``` After: ```ts import { fromPartial } from "@total-typescript/shoehorn"; getUser(fromPartial({ body: { id: "123" } })); ``` ### `as unknown as Type` → `fromAny()` Before: ```ts getUser({ body: { id: 123 } } as unknown as Request); // wrong type on purpose ``` After: ```ts import { fromAny } from "@total-typescript/shoehorn"; getU...

Details

Author
stevesolun
Repository
stevesolun/ctx
Created
2 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category