Skip to content

Correct the Message type union to the casing the API sends - #1

Merged
vernu merged 1 commit into
mainfrom
fix/message-type-casing
Aug 9, 2026
Merged

Correct the Message type union to the casing the API sends#1
vernu merged 1 commit into
mainfrom
fix/message-type-casing

Conversation

@vernu

@vernu vernu commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Message.type was declared 'sent' | 'received'. The API sends SENT and RECEIVED, and has since April 2024, so a consumer writing m.type === 'sent' got a comparison that typechecks, never matches, and gives no hint why.

The filter accepted by getMessages really is lowercase, so the asymmetry is genuine rather than a typo. The README and the response fixture in the tests now show both halves of it side by side, since that is the part people get wrong.

Also makes status optional. Messages stored before status tracking carry no value, so a required union was not true of the data.

Bumped to 0.0.3, which publishes on merge. The readme also said v0.0.1 while the package was on 0.0.2; that sentence no longer names a version, so it cannot go stale again.

Breaking for TypeScript consumers who compare against the old lowercase literals, though their comparisons were already dead at runtime.

The API returns SENT and RECEIVED uppercase, so `type: 'sent' | 'received'`
made every comparison a consumer writes against it fail silently while
typechecking cleanly. The filter accepted by getMessages stays lowercase,
so the README and the test now show both sides of that asymmetry.

Also makes status optional, since messages stored before status tracking
carry no value, and drops the stale version reference in the readme.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vernu
vernu merged commit efb66f1 into main Aug 9, 2026
1 check passed
@vernu
vernu deleted the fix/message-type-casing branch August 9, 2026 10:51
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