feat!: migrate to unthrown 1.0.0#265
Merged
Merged
Conversation
unthrown 1.0.0 renames the result constructors to PascalCase: `ok` → `Ok`,
`err` → `Err`, `defect` → `Defect`. Update every import and call site, bump the
`unthrown` / `@unthrown/vitest` catalog entries to 1.0.0, and move the published
packages' `unthrown` peer range to `^1`.
The `.match({ ok, err, defect })` handler keys stay lowercase (object keys, not
constructors); `matchTags` / `TaggedError` / `fromPromise` / `fromSafePromise` /
`.toAsync()` and `result.isOk()` / `isErr()` / `isDefect()` narrowing are
unchanged. Docs, agent rules, and the migration guide updated for the new
constructor names.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the repo to unthrown@1.0.0, migrating constructor usage from ok/err/defect to Ok/Err/Defect across packages, tests, examples, and documentation, and bumps the unthrown peer range to ^1 for published packages.
Changes:
- Bumped
unthrown+@unthrown/vitestto1.0.0via the pnpm catalog + lockfile updates. - Renamed
ok/errconstructor usage toOk/Erracross worker/client/contract source and tests. - Updated docs, agent rules, and added a major changeset describing the breaking change.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Bumps catalog versions for unthrown and @unthrown/vitest to 1.0.0. |
| pnpm-lock.yaml | Updates lockfile entries to reflect unthrown@1.0.0 and @unthrown/vitest@1.0.0. |
| packages/worker/src/workflow.ts | Updates docs/comments referencing Err(...) in workflow context docs. |
| packages/worker/src/errors.ts | Updates error docs to refer to Err(...) branch naming. |
| packages/worker/src/child-workflow.ts | Migrates runtime constructor calls/imports from ok/err to Ok/Err. |
| packages/worker/src/cancellation.ts | Migrates cancellation helpers to use Ok/Err constructors and updates docstrings. |
| packages/worker/src/cancellation.spec.ts | Updates test descriptions/comments for Err(...) naming. |
| packages/worker/src/activity.ts | Updates docs/comments describing Err(...) behavior at activity boundaries. |
| packages/worker/src/activity.spec.ts | Migrates tests to import/use Ok/Err (and derived okAsync/errAsync helpers). |
| packages/worker/src/tests/worker.spec.ts | Migrates worker integration tests to import/use Ok/Err. |
| packages/worker/package.json | Bumps unthrown peer dependency range to ^1. |
| packages/contract/src/result-async.ts | Updates internal docs to refer to Ok/Err constructors. |
| packages/contract/src/result-async.spec.ts | Migrates contract tests to import/use Ok/Err. |
| packages/contract/package.json | Bumps unthrown peer dependency range to ^1. |
| packages/client/src/schedule.ts | Migrates schedule client logic to import/use Ok/Err. |
| packages/client/src/internal.ts | Migrates internal client helpers to import/use Ok/Err and updates docs. |
| packages/client/src/client.ts | Migrates typed client constructors/imports to Ok/Err across operations. |
| packages/client/package.json | Bumps unthrown peer dependency range to ^1. |
| examples/order-processing-worker/src/application/activities.ts | Updates example activity docs/comments to reference Err(...) naming. |
| docs/guide/worker-usage.md | Updates guide examples to use Ok/Err constructors (import inconsistency noted). |
| docs/guide/troubleshooting.md | Updates troubleshooting examples/comments for Ok/Err (import inconsistency noted). |
| docs/guide/result-pattern.md | Updates result-pattern docs to reference Err(...) constructor naming. |
| docs/guide/migrating-to-unthrown.md | Updates migration guide for unthrown@1 constructor naming + narrowing notes. |
| docs/guide/entry-points.md | Updates guide code blocks to Ok(...) usage (import inconsistency noted). |
| docs/guide/client-usage.md | Updates guide client mock example to return Ok(...) (import inconsistency noted). |
| docs/guide/activity-handlers.md | Updates guide mock activity examples to return Ok(...) (import inconsistency noted). |
| AGENTS.md | Updates agent guidance to reference Err(...).toAsync() for modeled failures. |
| .changeset/unthrown-v1.md | Adds major changeset describing the breaking rename + peer bump. |
| .agents/rules/workflow-determinism.md | Updates determinism rule docs to reference Err(...) cancellation behavior. |
| .agents/rules/handlers.md | Updates handler rules to reference Ok/Err(...).toAsync() and Err(...) cancellation branch. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
The v1.0.0 rename updated the `Ok(...)` / `Err(...)` call sites in the guide
code blocks but left their `import { ok, err } from "unthrown"` lines
lowercase, so the snippets were internally inconsistent. Rename the imports to
the PascalCase constructors (free functions `isOk` / `isErr` / `isDefect` are
unchanged).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades to
unthrown1.0.0, which renames the result constructors to PascalCase:ok→Ok,err→Err,defect→Defect. Follows the original neverthrow→unthrown migration (#263, merged) and the 0.2.0 upgrade.What changed
ok/err/defect→Ok/Err/Defectacross all imports and call sites (source, tests, examples).result.match({ ok, err, defect })handler keys stay lowercase (they're object keys, not constructors);matchTags/TaggedError/fromPromise/fromSafePromise/.toAsync(); andresult.isOk()/isErr()/isDefect()narrowing.unthrown+@unthrown/vitestcatalog →1.0.0; published packages'unthrownpeer range →^1.majorchangeset for all four packages (theunthrown ^1peer bump + constructor rename are breaking for consumers who construct results directly).Verification
typecheck · oxlint · oxfmt · knip · 271 unit tests · integration tests (8/8 turbo tasks) · docs build — all green.
🤖 Generated with Claude Code