Skip to content

feat(assert-never): add assertNever helper for exhaustive switch/case - #5

Merged
jhnns merged 1 commit into
mainfrom
assert-never-helper
Aug 3, 2026
Merged

feat(assert-never): add assertNever helper for exhaustive switch/case#5
jhnns merged 1 commit into
mainfrom
assert-never-helper

Conversation

@jhnns

@jhnns jhnns commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds assertNever, a helper for the default branch of switch/case statements over union types — it only accepts never, so TypeScript flags a missing case at compile time, and it throws a TypeError at runtime if reached.
  • Exported as a new sub-package (@peerigon/typescript-toolkit/assert-never) with its own README, size-limit entry (200 B brotli), and unit tests.
  • Updates root README.md utilities table and package.json/jsr.json exports accordingly.

Test plan

  • npm test (format, lint, types, unit tests) passes
  • npx size-limit passes for the new sub-package

🤖 Generated with Claude Code

Provides a typed helper for the default branch of switch/case statements over
union types, throwing at runtime and failing compilation if a case is missed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@peerigon/typescript-toolkit@5

commit: 238cb0b

@jhnns
jhnns merged commit 0ebbf2b into main Aug 3, 2026
3 checks passed
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