migrate-to-shoehorn
将测试文件中的 `as` 类型断言迁移到 @total-typescript/shoehorn。用户提到 shoehorn、希望替换测试中的 `as`,或需要部分测试数据时使用。
译文已校对查看英文原文
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.
适用对象:软件开发与测试。自动收录 · 待核查。
原作者说明节选
从固定版本的 SKILL.md 提取,保留原文语言。以下内容属于作者说明,本站尚未验证安装、兼容或运行结果。
查看英文原文
原文涵盖的主题
- Migrate to Shoehorn
- Why shoehorn?
- Install
- Migration patterns
- Large objects with few needed properties
- as Type → fromPartial()
- as unknown as Type → fromAny()
- When to use each
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 Before: After: Before: After: Before: After: | 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) | 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 [ ] R
这里只展示节选,请以完整原文和当前要求为准。
- 来源仓库
- mattpocock/skills
- 源文件
- skills/misc/migrate-to-shoehorn/SKILL.md
- 固定版本
- 4ae2317ddb22b046e26455e4f9c9b3aaaf62212d
来源与内容状态
本条为自动发现的元数据,尚未完成人工文档核查;适用性与运行结果待核查。
原作者:Matt Pocock Skills · 原作者仓库元数据。文档核查:未核查。最近来源检查:2026-11-10T22:01:34.087Z。
分类由名称、说明与路径规则生成,分类不代表已核实适配。
许可与权利归属
MIT。第三方内容及版权归原作者,使用条件以原文为准。
许可原文 ↗本站没有因同步、复制或用户自报成功而将资源标为运行验证通过。
限制与注意事项
- 元数据收录不代表本站已经安装、适配、实测或进行安全审查。