Skip to content

feat!: migrate to unthrown 1.0.0#265

Merged
btravers merged 2 commits into
mainfrom
feat/unthrown-v1
Jun 27, 2026
Merged

feat!: migrate to unthrown 1.0.0#265
btravers merged 2 commits into
mainfrom
feat/unthrown-v1

Conversation

@btravers

Copy link
Copy Markdown
Collaborator

Summary

Upgrades to unthrown 1.0.0, which renames the result constructors to PascalCase: okOk, errErr, defectDefect. Follows the original neverthrow→unthrown migration (#263, merged) and the 0.2.0 upgrade.

What changed

  • Constructor rename ok/err/defectOk/Err/Defect across all imports and call sites (source, tests, examples).
  • Unchanged (verified): the result.match({ ok, err, defect }) handler keys stay lowercase (they're object keys, not constructors); matchTags / TaggedError / fromPromise / fromSafePromise / .toAsync(); and result.isOk() / isErr() / isDefect() narrowing.
  • Deps: unthrown + @unthrown/vitest catalog → 1.0.0; published packages' unthrown peer range → ^1.
  • Docs / agent rules / migration guide updated for the new constructor names; the guide's stale "free functions narrow, methods don't" rationale is dropped (methods narrow since 0.2.0) and replaced with the maintenance motivation (supermacro/neverthrow#670).
  • major changeset for all four packages (the unthrown ^1 peer 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

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>
Copilot AI review requested due to automatic review settings June 27, 2026 22:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/vitest to 1.0.0 via the pnpm catalog + lockfile updates.
  • Renamed ok/err constructor usage to Ok/Err across 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

Comment thread docs/guide/worker-usage.md
Comment thread docs/guide/client-usage.md
Comment thread docs/guide/activity-handlers.md
Comment thread docs/guide/entry-points.md Outdated
Comment thread docs/guide/entry-points.md
Comment thread docs/guide/entry-points.md Outdated
Comment thread docs/guide/troubleshooting.md Outdated
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>
@btravers btravers merged commit 0716b5d into main Jun 27, 2026
9 checks passed
@btravers btravers deleted the feat/unthrown-v1 branch June 27, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants