migrate-to-shoehorn
- Use it when:
- Your tests use `as` assertions to pass partial or deliberately wrong data to typed functions.
- It does:
- Installs shoehorn and replaces `as Type` with fromPartial() and `as unknown as Type` with fromAny() in your test files.
- You get:
- Tests that pass only the properties they need and still type-check, confirmed by a type check at the end.
- Keeps:
- shoehorn out of production code: it touches test files only.
- From:
- Matt Pocock, who maintains shoehorn.
- Runs:
- By itself when you mention shoehorn, want `as` out of your tests, or need partial test data.
TL;DR
shoehorn (@total-typescript/shoehorn) is a small library for test data. A test often has to pass a large object, such as a request, when it only cares about one property, so people fake the whole object or silence TypeScript with `as`. With shoehorn, fromPartial() takes a partial object and still type-checks, fromAny() passes intentionally wrong data while keeping autocomplete, and fromExact() demands the full object until you swap it for fromPartial(). The agent first asks which test files have troublesome assertions and whether you need wrong data for error tests. It then installs the package with npm, searches .test.ts and .spec.ts files for `as` assertions, swaps each for the matching function, adds the imports and runs a type check.
Summarizes the skill at 4ae2317.
npx skills add https://github.com/mattpocock/skills --skill migrate-to-shoehorn skills.sh pageSource on GitHubAll skills from mattpocock/skills
- Total Downloads
- 522,700 on skills.sh, Nov 9, 2026
- Repo stars
- 318,714 mattpocock/skills
- First seen
- Feb 13, 2026 on skills.sh
Weekly values
| Week to | Installs |
|---|---|
| Sep 21 | 25,997 |
| Sep 28 | 23,103 |
| Oct 5 | 22,681 |
| Oct 12 | 28,413 |
| Oct 19 | 25,063 |
| Oct 26 | 22,748 |
| Nov 2 | 20,924 |
| Nov 9 | 20,179 |
| Category |
Test-first work, implementation from specs, git hygiene and scope control. Guides for frameworks, databases and SDKs, mostly from their vendors. Everything for building software: planning, coding, debugging, design, frameworks, cloud, agents and skills. |
|---|---|
| Type |
A multi-step process the agent follows: interview, debug, run a TDD loop, review. |
| Effect |
Its own steps create or change files, git state or local tools. |
| Needs |
Instructions only. Works in any agent that supports skills. |
| Publisher |
A verified publisher on skills.sh, or the company or maintainer behind the product the skill operates. |
| Topics | |
| Stack |
SKILL.md
From mattpocock/skills at 4ae2317. Checked daily, last changed Nov 9, 2026.
Frontmatter
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.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
npm i @total-typescript/shoehorn
Migration patterns
Large objects with few needed properties
Before:
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:
import { fromPartial } from "@total-typescript/shoehorn";
it("gets user by id", () => {
getUser(
fromPartial({
body: { id: "123" },
}),
);
});
as Type → fromPartial()
Before:
getUser({ body: { id: "123" } } as Request);
After:
import { fromPartial } from "@total-typescript/shoehorn";
getUser(fromPartial({ body: { id: "123" } }));
as unknown as Type → fromAny()
Before:
getUser({ body: { id: 123 } } as unknown as Request); // wrong type on purpose
After:
import { fromAny } from "@total-typescript/shoehorn";
getUser(fromAny({ body: { id: 123 } }));
When to use each
| Function | Use case |
|---|---|
fromPartial() |
Pass partial data that still type-checks |
fromAny() |
Pass intentionally wrong data (keeps autocomplete) |
fromExact() |
Force full object (swap with fromPartial later) |
Workflow
-
Gather requirements - ask user:
- What test files have
asassertions causing problems? - Are they dealing with large objects where only some properties matter?
- Do they need to pass intentionally wrong data for error testing?
- What test files have
-
Install and migrate:
- [ ] Install:
npm i @total-typescript/shoehorn - [ ] Find test files with
asassertions:grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts" - [ ] Replace
as TypewithfromPartial() - [ ] Replace
as unknown as TypewithfromAny() - [ ] Add imports from
@total-typescript/shoehorn - [ ] Run type check to verify
- [ ] Install: