Migrate To Shoehorn

Migrate test casts from `as` to @total-typescript/shoehorn.

redpanda-data 579b02d 831 B Updated 6 repo stars

File contents

Migrate to Shoehorn

Test code only. Never prod.

@total-typescript/shoehorn replaces test as casts with type-safe helpers for partial data.

Install

bun add -d @total-typescript/shoehorn

Patterns

as Type with partial object -> fromPartial():

import { fromPartial } from "@total-typescript/shoehorn";
getUser(fromPartial({ body: { id: "123" } }));

Intentionally invalid data -> fromPartial() plus targeted override helper from package docs. Avoid as unknown as.

Workflow

  1. Limit to tests: *.test.*, *.spec.*, fixtures.
  2. Find casts: rg " as |as unknown as".
  3. Replace one cluster at a time.
  4. Run related tests + type check.
  5. Keep production files untouched.

redpanda-data/ui-harness/tree/main/migrate-to-shoehorn commit 579b02d2ed

Frequently asked questions

npx skillmds@latest add redpanda-data/migrate-to-shoehorn