
Migrate To Shoehorn
This automates the migration from `as` type assertions to shoehorn in your test files. It's specifically for cleaning up tests where you're faking large objects but only care about a few properties, or intentionally passing bad data to test error paths. The skill installs the shoehorn package, searches for `as` assertions in test files, and replaces them with `fromPartial()` or `fromAny()` depending on whether you're passing partial valid data or deliberately wrong types. It's a focused refactor that makes test setup less brittle without changing runtime behavior. Only applies to test code, which is the right call since shoehorn should never touch production.
- skills.sh installs
- 5.6K
- GitHub stars
- 5.7K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add vinvcn/mattpocock-skills-zh-cn --skill migrate-to-shoehorn --agent claude-codeInstalls into .claude/skills of the current project.
Files
迁移到 Shoehorn
为什么用 shoehorn?
shoehorn 允许你在 tests 中传入 partial data,同时保持 TypeScript 满意。它用 type-safe alternatives 替换 as assertions。
只用于 test code。 永远不要在 production code 中使用 shoehorn。
Tests 中 as 的问题:
- 经过训练,不去使用它
- 必须手动指定 target type
- 对故意错误的数据需要 double-as(
as unknown as Type)
安装
npm i @total-typescript/shoehorn
迁移模式
只需要少数属性的大型 objects
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:
Sponsors
Details
- Repository
- github.com/vinvcn/mattpocock-skills-zh-cn
- First seen
- Jun 3, 2026
More from vinvcn/mattpocock-skills-zh-cn
All 39- Teach5.4K
- Grilling4.7K
- Domain Modeling4.4K
- Code Review4.4K
- Ask Matt4.4K
- Diagnosing Bugs4.4K
- Implement4.3K
- Codebase Design4.3K
- Research4.2K
- Writing Shape3.7K
- Writing Fragments3.7K
- Writing Beats3.7K
- Resolving Merge Conflicts3.5K
- To Prd2.2K
- Design An Interface2.1K
- To Issues2.1K
- Qa2.1K
- Edit Article2.1K
- Obsidian Vault2.1K
- Request Refactor Plan2.1K
- Ubiquitous Language2.1K
- Writing Great Skills2.1K
- Diagnose1.7K
- Caveman1.7K