migrate-to-shoehorn
仓库创建 2026年7月6日最近提交 22 天前SkillHot 收录 22 天前
▸ 精选理由
自动化迁移测试断言,减少不安全的 as 用法,适合 TypeScript 项目维护者。
这个 Skill 做什么
将测试中的 `as` 类型断言替换为 @total-typescript/shoehorn 的类型安全写法。
把测试里那种随手写的 `as` 类型断言换成 @total-typescript/shoehorn 的安全写法,让测试能传不完整数据又不踩类型坑。只用于测试代码,不要放进生产代码里。它的好处是保持 TypeScript 类型安全、减少双重断言(like `as unknown as Type`),更容易写部分测试数据。
▸ 展开 SKILL.md 英文原文
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.
0
Stars
0
Forks
38
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/K3639284/skills/main/skills/misc/migrate-to-shoehorn/SKILL.md或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/K3639284/skills/main/skills/misc/migrate-to-shoehorn/SKILL.md"SKILL.MD 节选查看完整文件 ↗
# 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
```bash
npm i @total-typescript/shoehorn
```
## Migration patterns
### Large objects with few needed properties
Before:
```ts
type Request = {
body: { id: string };
headers: Record<string, string>;
cookies: Record<string, string>;
// ...20 more properties
};
it("gets user by id", (via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有