Skip to content

refactor(errors): move ErrorInstance implementation to a private class - #91

Merged
martyy-code merged 1 commit into
stagingfrom
feat/88-class-internals
Oct 7, 2026
Merged

martyy-code merged 1 commit into
stagingfrom
feat/88-class-internals

Conversation

@martyy-code

Copy link
Copy Markdown
Contributor

Closes #88. Consolidated version of the original spike/88-class-internals PR #89, squashed into one commit and rebased on staging (post-#82, #85, #84).

What

Moves the ErrorInstance implementation to a private class (ErrorInstanceImpl) while keeping the function-based public API. The class extends Error so instance instanceof Error is true. The brand marker is a readonly class property.

Why one commit

PR #89 was a 6-commit stack (class intro → drop casts → split into internal/ → extract config type → final polish → style). Rebasing the full stack on top of #82, #85, and #84 produced cascading conflicts on every commit. Consolidating to the final state of the diff sidesteps the conflicts and lands the same end result.

Verification

  • pnpm type-check (in progress)
  • pnpm test (in progress)
  • pnpm build (in progress)

Applied as a single consolidated commit on top of staging (post-#84).
Original PR #89 was a 6-commit stack; this collapses to the final
state so the structural rewrite (class internals) lands cleanly
without incremental rebase conflicts.

- New private class ErrorInstanceImpl in internal/error-instance-impl.ts
- New private class ErrorFactoryImpl in internal/error-factory-impl.ts
- error() now returns a callable bound to an ErrorFactoryImpl
- ErrorInstance extends Error at runtime; instance instanceof Error
  is true
- Brand marker (ErrorInstanceBrand) set as readonly class property
- FACTORY_SYMBOL consolidated in types.ts (single source of truth)
- ErrorConfig renamed to ErrorFactoryConfig and now exported
- Tests cover instance class, brand marker, and Error prototype

Closes #88.
@martyy-code
martyy-code merged commit ce629c4 into staging Oct 7, 2026
4 of 5 checks passed
@martyy-code
martyy-code deleted the feat/88-class-internals branch October 7, 2026 13:41
codewizdave pushed a commit that referenced this pull request Oct 7, 2026
Resync after #91 was merged to staging but main had moved to 1.4.0
with RFC 0001 already published. Staging is now rebased on main; this
merge publishes the 4 pending changesets as version 1.5.0.

Changesets in this release:
- fix-71: FACTORY_SYMBOL as a typed property
- fix-74: structural guard in causes()
- feat-83: Standard Schema inference (subsumed by RFC 0001 in 1.4.0)
- feat-88: class-based internals (replaced by 1.4.0's function-based impl)
codewizdave pushed a commit that referenced this pull request Oct 7, 2026
Resync after #91 was merged to staging but main had moved to 1.4.0
with RFC 0001 already published. Staging is now rebased on main; this
merge publishes the 4 pending changesets as version 1.5.0.

Changesets in this release:
- fix-71: FACTORY_SYMBOL as a typed property
- fix-74: structural guard in causes()
- feat-83: Standard Schema inference (subsumed by RFC 0001 in 1.4.0)
- feat-88: class-based internals (replaced by 1.4.0's function-based impl)
codewizdave pushed a commit that referenced this pull request Oct 7, 2026
Resync after #91 was merged to staging but main had moved to 1.4.0
with RFC 0001 already published. Staging is now rebased on main; this
merge publishes the 4 pending changesets as version 1.5.0.

Changesets in this release:
- fix-71: FACTORY_SYMBOL as a typed property
- fix-74: structural guard in causes()
- feat-83: Standard Schema inference (subsumed by RFC 0001 in 1.4.0)
- feat-88: class-based internals (replaced by 1.4.0's function-based impl)
codewizdave pushed a commit that referenced this pull request Oct 7, 2026
Resync after #91 was merged to staging but main had moved to 1.4.0
with RFC 0001 already published. Staging is now rebased on main; this
merge publishes the 4 pending changesets as version 1.5.0.

Changesets in this release:
- fix-71: FACTORY_SYMBOL as a typed property
- fix-74: structural guard in causes()
- feat-83: Standard Schema inference (subsumed by RFC 0001 in 1.4.0)
- feat-88: class-based internals (replaced by 1.4.0's function-based impl)

Also applies prettier --write across the repo to clear the accumulated
format drift that was failing the Lint CI on every push. Pure formatting
changes; no functional impact. All 167 tests still pass.
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