Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL
All skills

migrate-to-shoehorn

Replace `as` type assertions in test files with type-safe @total-typescript/shoehorn helpers.

When to use it

Your test files are cluttered with `as` or `as unknown as` casts to fake large objects, and you want to pass only the fields each test needs.

For example

You say

Use migrate-to-shoehorn to convert the `as Request` casts in getUser.test.ts to fromPartial so I only pass body.id.

You get
  • Updated test file
  • fromPartial imports added
  • Type check passes

How it works

  • `as unknown as Type` becomes `fromAny()` for intentionally wrong data.
  • `fromExact()` forces a full object you can loosen to `fromPartial()` later.

Before installing

Requires installing the @total-typescript/shoehorn npm package; it is meant for test code only, never production code.