-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strongly typed client #455
Merged
Merged
Conversation
This file contains 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
Deploying with Cloudflare Pages
|
…mtp-js-sdk into nmolnar/strongly-typed-client
neekolas
commented
Sep 13, 2023
rygine
reviewed
Sep 13, 2023
rygine
reviewed
Sep 13, 2023
rygine
approved these changes
Sep 13, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits, but nothing blocking. great work, LGTM!
🎉 This PR is included in version 11.0.0-beta.11 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Merged
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.
Summary
A long-standing source of frustration with our JS SDK is the use of
any
types for message content. Sending and receiving messages has thecontent
field typed asany
.Message content is of a finite set of types, defined by the codecs that get passed in to Client creation. If you have a codec that returns
number
, it's possible to get messages with content of type number. If you don't a number codec, it's not possible.We just need to do some Typescript wrangling to infer those types from the codecs and pass them around to all the conversation methods.
This PR does that.
Notes
I've structured this to be safe for existing implementers. All the existing types default to
any
. This will make the migration path smoother for developers, but also may lead devs to not take advantage of this feature.