Loading...
Loading...
Use this skill when > Migrate TypeScript test files from unsafe `as` type assertions to type-safe alternatives from @total-typescript/shoehorn. Replace `obj as Type` with fromPartial(), `obj as unknown as Type` with fromAny(), and complete specs with fromExact(). Test code only — never use in production.
npx skill4agent add akillness/oh-my-skills migrate-to-shoehornas@total-typescript/shoehornasas unknown as Typezodnpm i @total-typescript/shoehornfromPartial<T>(partial)// Before (unsafe)
const user = { name: "Alice" } as User
// After (type-safe, keeps autocomplete)
import { fromPartial } from "@total-typescript/shoehorn"
const user = fromPartial<User>({ name: "Alice" })fromAny<T>(value)// Before (verbose double-as)
const badInput = { invalid: true } as unknown as User
// After
import { fromAny } from "@total-typescript/shoehorn"
const badInput = fromAny<User>({ invalid: true })fromExact<T>(complete)// Before
const user = { name: "Alice", email: "alice@example.com", id: 1 } as User
// After (TypeScript will error if any field is missing)
import { fromExact } from "@total-typescript/shoehorn"
const user = fromExact<User>({ name: "Alice", email: "alice@example.com", id: 1 })asgrep -rn " as " --include="*.test.ts" --include="*.spec.ts" --include="*.test.tsx"fromPartial()fromAny()fromExact()import { fromPartial, fromAny, fromExact } from "@total-typescript/shoehorn"npx tsc --noEmitfromPartialfromAnyfromExact.agent-skills/skill-standardization/SKILL.md.agent-skills/skill-standardization/scripts/validate_skill.sh