xxih/ai-harness-zh/migrate-to-shoehorn
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
把测试文件里的 `as` 类型断言迁到 @total-typescript/shoehorn。当用户提到 shoehorn、想替换测试里的 `as`,或需要传部分测试数据时使用。
Install
npx vskill@latest install xxih/ai-harness-zh/migrate-to-shoehornSKILL.md
Migrate to Shoehorn
为什么用 shoehorn
shoehorn 让你在测试里传部分数据的同时让 TypeScript 满意。用类型安全的替代物替换 as 断言。
只在测试代码。永远不要在生产代码用 shoehorn。
测试里用 as 的问题:
- 大家被教育"别用 as"
- 必须手动指定目标类型
- 故意传错数据时要 double-as(
as unknown as Type)
安装
迁移模式
大对象,只关心几个字段
之前:
之后:
as Type → fromPartial()
之前:
之后:
as unknown as Type → fromAny()
之前:
之后:
各函数何时用
| 函数 | 用法 | |
|---|---|---|
fromPartial() | 传部分数据,仍然类型检查 | |
fromAny() | 故意传错类型的数据(保留自动补全) | |
fromExact() | 强制完整对象(以后可换回 fromPartial) |
工作流
- 采集需求 —— 问用户:
- 哪些测试文件里
as断言有问题? - 是不是大对象只关心几个字段?
- 需不需要传故意错的数据做错误路径测试?
- 安装 + 迁移:
- [ ] 装:
npm i @total-typescript/shoehorn - [ ] 找测试里的
as:grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts" - [ ]
as Type换fromPartial() - [ ]
as unknown as Type换fromAny() - [ ] 加
@total-typescript/shoehorn的 import - [ ] 跑类型检查验证
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingreferences/translations/mattpocock-skills/skills/misc/migrate-to-shoehorn/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/xxih/ai-harness-zh/migrate-to-shoehorn)