Skip to content

allow ErrorOpts as first arg for no-param errors#4

Merged
gmaclennan merged 3 commits into
mainfrom
feat/error-opts-first-param
Mar 3, 2026
Merged

allow ErrorOpts as first arg for no-param errors#4
gmaclennan merged 3 commits into
mainfrom
feat/error-opts-first-param

Conversation

@gmaclennan

Copy link
Copy Markdown
Member

Summary

  • For errors without template params, new Err({ cause }) is now a valid shorthand for new Err(undefined, { cause })
  • Parameterized errors are unaffected — their first object arg is still treated as params
  • Adds new (opts: ErrorOpts) TypeScript overload to the no-params constructor branch

Test plan

  • All 46 existing tests still pass unchanged
  • 8 new integration tests covering: { cause } as first arg, falsy cause, { cause: undefined }, empty {}, parameterized errors unaffected, existing signatures still work, cause non-enumerable
  • New tsd type tests: ErrorOpts compiles for no-param errors, expectError for parameterized errors
  • npm test passes (both runtime and type tests)

🤖 Generated with Claude Code

gmaclennan and others added 3 commits March 3, 2026 10:15
For errors without template params, `new Err({ cause })` is now a
valid shorthand for `new Err(undefined, { cause })`. Parameterized
errors are unaffected — their first object arg is still treated as
params.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Brings in non-string template parameter support (inspect utility,
updated types, and tests) from main.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gmaclennan gmaclennan merged commit c830dd8 into main Mar 3, 2026
3 checks passed
@gmaclennan gmaclennan deleted the feat/error-opts-first-param branch March 3, 2026 17:38
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.

1 participant