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

Convert REST response type to tagged union #115

Closed
ecxyzzy opened this issue Dec 4, 2023 · 0 comments · Fixed by #134
Closed

Convert REST response type to tagged union #115

ecxyzzy opened this issue Dec 4, 2023 · 0 comments · Fixed by #134
Assignees
Labels
area: rest-api Related to the REST API specifically priority: low Low priority issue story point: 1 Quick copy change type: chore All other necessary (but less impactful) tasks
Milestone

Comments

@ecxyzzy
Copy link
Member

ecxyzzy commented Dec 4, 2023

Currently, to determine whether a RawResponse<T> is a Response<T> or an ErrorResponse, we test whether the payload field exists. This is kind of cumbersome and is why we ship an isErrorResponse function with the types package, but we could just add success: true to the former variant of RawResponse<T> and success: false to the latter.

This would make error checking as simple as testing res.success, and would also allow consumers of the types package to only add it as a devDependency (not sure if the latter matters as much though).

@ecxyzzy ecxyzzy added priority: low Low priority issue story point: 1 Quick copy change type: chore All other necessary (but less impactful) tasks area: rest-api Related to the REST API specifically labels Dec 4, 2023
@y-dejong y-dejong self-assigned this Jan 18, 2024
@jordany33 jordany33 self-assigned this Jan 18, 2024
@ecxyzzy ecxyzzy added this to the 1.0 milestone Feb 29, 2024
@ecxyzzy ecxyzzy linked a pull request Mar 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: rest-api Related to the REST API specifically priority: low Low priority issue story point: 1 Quick copy change type: chore All other necessary (but less impactful) tasks
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants