migrate-to-shoehorn
$
npx mdskill add mkurman/zorai/migrate-to-shoehornReplace as assertions with shoehorn functions in test files.
- Handles partial data passing and intentional error testing.
- Depends on @total-typescript/shoehorn package installation.
- Uses grep to locate as assertions in test files.
- Outputs migrated code with updated imports and function calls.
SKILL.md
.github/skills/migrate-to-shoehornView on GitHub ↗
--- name: migrate-to-shoehorn description: 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. tags: [mattpocock, migrate-to-shoehorn, typescript] ------------ | -------------------------------------------------- | | `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