mit einem Klick
better-result-migrate-v2
// Migrate better-result TaggedError usage from the v1 class-based API to the v2 factory-based API. Use when upgrading a codebase that still extends TaggedError directly or calls the old static helpers.
// Migrate better-result TaggedError usage from the v1 class-based API to the v2 factory-based API. Use when upgrading a codebase that still extends TaggedError directly or calls the old static helpers.
| name | better-result-migrate-v2 |
| description | Migrate better-result TaggedError usage from the v1 class-based API to the v2 factory-based API. Use when upgrading a codebase that still extends TaggedError directly or calls the old static helpers. |
| references | ["references/migration-patterns.md"] |
Upgrade better-result error definitions from the v1 TaggedError API to the v2 factory-based API.
Use this skill when the user:
better-result from v1 to v2extend TaggedError directlyTaggedError.match, TaggedError.matchPartial, or TaggedError.isTaggedError| Task | Files to Read |
|---|---|
| Plan and execute the migration | This file |
| See concrete before/after transforms | references/migration-patterns.md |
| Verify current library behavior | opensrc/ if present |
| v1 | v2 |
|---|---|
class FooError extends TaggedError | class FooError extends TaggedError("FooError")<Props>() {} |
readonly _tag = "FooError" as const | _tag generated by the factory |
new FooError("123") | new FooError({ id: "123", message: "..." }) |
TaggedError.match(...) | matchError(...) |
TaggedError.matchPartial(...) | matchErrorPartial(...) |
TaggedError.isTaggedError(...) | isTaggedError(...) or TaggedError.is(...) |
extends TaggedError across the codebase._tag literalTaggedError("Tag")<Props>().super({...})._tag, replace base class, move fields into the generic props object.message before super(...).super(...).new FooError(a, b) to new FooError({ a, b, message }) or an equivalent derived-message constructor.Read references/migration-patterns.md before editing if the target classes are non-trivial.
Search for all of these before and after the migration:
extends TaggedErrorreadonly _tag =TaggedError.matchTaggedError.matchPartialTaggedError.isTaggedErrornew call sites for migrated error classesA migration is complete when:
TaggedError base classTaggedError("...")<...>()matchError, matchErrorPartial, or isTaggedErrormessage in the props shapeTaggedError.match but missing matchPartial or isTaggedError| File | Purpose |
|---|---|
references/migration-patterns.md | Detailed v1 → v2 before/after examples and import helper changes |
If opensrc/ exists, use it to confirm the exact v2 API exposed by the installed package.
Audit better-result changes or PRs against known Prisma and Better T Stack downstream dependents. Use when working on better-result API/type/runtime changes and the user asks whether a change breaks Prisma dependents, Better T Stack dependents, npm dependents, or PR compatibility.
Adopt better-result in an existing TypeScript codebase. Use when replacing try/catch, Promise rejection handling, null sentinels, or thrown domain exceptions with typed Result workflows.