Migrate To Shoehorn

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.

mkurman Updated

File contents

--------- | -------------------------------------------------- | | fromPartial() | Pass partial data that still type-checks | | fromAny() | Pass intentionally wrong data (keeps autocomplete) | | fromExact() | Force full object (swap with fromPartial later) |

Workflow

  1. Gather requirements - ask user:

    • What test files have as assertions causing problems?
    • Are they dealing with large objects where only some properties matter?
    • Do they need to pass intentionally wrong data for error testing?
  2. Install and migrate:

    • Install: npm i @total-typescript/shoehorn
    • Find test files with as assertions: grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"
    • Replace as Type with fromPartial()
    • Replace as unknown as Type with fromAny()
    • Add imports from @total-typescript/shoehorn
    • Run type check to verify

mkurman/zorai/tree/main/skills/mattpocock/migrate-to-shoehorn commit 1732d9a828

Frequently asked questions

npx skillmds@latest add mkurman/migrate-to-shoehorn