Skip to content
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

Remove need for casting in rpc endpoint #248

Closed
wants to merge 3 commits into from
Closed

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Oct 27, 2023

When digging into a some errors that were raised in this file I found there was a bunch of as MessageMap[typeof SOMETHING] casting happening because we structured this code in a way that typescript isn't able to infer data shapes on its own.

This PR refactors the contents of this file so that the data variable is typed in a way that when you use the switch statement do different things based upon the value of data[0], the value of data[1] is correctly narrowed to the expected type without the need for casting from any.

Tophat

In vscode inspect the the type of the data / data[1] values in within the switch statement by hovering over them and looking at what autcomplete tells you and see that they get correctly inferred.

@github-actions
Copy link
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset directory.
If the changes are user-facing and should cause a version bump, run yarn changeset to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to repo configuration, examples, or documentation, you do not need to add a changeset.

@BPScott BPScott changed the title Remvoe need for casting in rpc endpoint Remove need for casting in rpc endpoint Oct 30, 2023
@lemonmade
Copy link
Member

Sorry Ben, lost track of this. I ended up redoing this work with a few less changes to the code structure itself, in order to avoid the complexity of resolving merge conflicts: e701fb0

@lemonmade lemonmade closed this Feb 16, 2024
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.

2 participants