Correct the Message type union to the casing the API sends - #1
Merged
Conversation
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>
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.
Message.typewas declared'sent' | 'received'. The API sendsSENTandRECEIVED, and has since April 2024, so a consumer writingm.type === 'sent'got a comparison that typechecks, never matches, and gives no hint why.The filter accepted by
getMessagesreally 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
statusoptional. 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.