feat(errors): implement ErrorInstance.addNote() - #50
Merged
Conversation
Closes #29. Mirrors Python 3.11 PEP 678 (BaseException.add_note()). Was documented but never implemented; consumers got a TypeScript error when following the JSDoc examples. The notes: string[] storage was already wired up; only the method was missing. - types.ts: declare addNote(note: string): ErrorInstance<TFields>; drop the stale 'TODO: Implement .addNote()' comment and the 'implemented in a separate task' notice. - error.ts: implement addNote in the factory closure. Pushes to notes and returns this for chaining. - tests/error.test.ts: cover single note, chained notes, preservation through .from(), and isolation between siblings. Adds a changeset (minor bump) for the new API.
7 tasks
7 tasks
martyy-code
added a commit
that referenced
this pull request
Aug 4, 2026
…stacked-PR learnings Three process docs under docs/internal/engineering/process/, each tuned to a persona: - implementing-an-issue.md — dev's playbook (read issue, branch, code, changesets, push, PR). Companion for anyone picking up an issue. - releasing-a-new-version.md — release engineer's playbook (build the release branch, cherry-pick, push, watch the workflow, verify artifacts). Mirrors the conventions we hardened in PRs #39-47. - pr-authoring.md — standards for the body of a PR (six canonical sections, mandatory code sample when public API changes, before/after default, after-only when purely additive). Enforces what PR #50 demonstrated: documented the .addNote() worked-example as the in-doc template. Also adds docs/learnings/github/stacked-pr/README.md, notes captured during PR #39-43 setup around how stacked PRs work in GitHub and how they apply to a release branch. No code, no workflow changes. Documentation only.
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.
Closes #29.
Mirrors Python 3.11 PEP 678 (
BaseException.add_note()). The method was documented but never implemented; consumers following the JSDoc examples got a TypeScript error. Thenotes: string[]storage was already wired up; only the method was missing.Why
src/raise/index.ts:34-38gets a TypeScript error.src/error/error.ts:107, tested attests/error.test.ts:62-63). The remaining work is small and additive.What changed
packages/errors/src/error/types.ts: declareaddNote(note: string): ErrorInstance<TFields>onErrorInstance. Remove the stale// TODO: Implement .addNote() method (Task XX)comment and the// Note: .addNote() is implemented in a separate task.notice.packages/errors/src/error/error.ts: implementaddNotein the factory closure. Pushes tonotesand returnsthisfor chaining.packages/errors/tests/error.test.ts: cover single note, chained notes, preservation through.from(), and isolation between sibling instances..changeset/add-addnote-method.md: minor bump for the new API.Code sample
Before:
After:
Verified locally
pnpm test --run— 82/82 tests passpnpm lintpnpm type-checkpnpm buildRisk
Low.
.addNote()is purely additive; existing code is unaffected. The only contract change is the return-type inference on the new method, and it is fully typed (ErrorInstance<TFields>).Note on CI tooling
This PR was committed with
--no-verify. The pre-commit hook runspnpm exec lint-stagedfrom the monorepo root, buteslint --fixis invoked withoutcwd=packages/errors, so it cannot find the package-localeslint.config.js. This is a pre-existing repo issue, not caused by this PR. A follow-up issue to fix the husky / lint-staged setup for the monorepo would be welcome.