-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat: export proper ErrorResponse
type
#10811
Conversation
🦋 Changeset detectedLatest commit: 356f2a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
private error?: Error; | ||
private internal: boolean; |
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.
These should have been private all along, but since the entire class was a "private" implementation detail I think I glossed over the field specifiers. Marking them private ensures the type below doesn't include them.
ErrorResponse
type
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
This handles the callout in remix-run/remix#7238 which has come up a few times in discord as well.
We always wanted
class ErrorResponse
to be an implementation detail since it serves no runtime purpose in userland. We naively thoughtisRouteErrorResponse
's type narrowing would be sufficient, and is in the simple case:However, this is limited since you can't build abstractions around these errors:
The class was always marked
@private
and wasn't ever intended to be used, so this PR moves the class to anUNSAFE_ErrorResponseImpl
export. Because it was always marked "private", I don't consider this a breaking change.That frees up the
ErrorResponse
name so we can export a type of an instance of the class, which properly excludes the private properties:Then we can export this
ErrorResponse
type out through@remix-run/react
as well.Main changes are in
utils.ts
- the rest is just bubbling the name changes out and exporting the new type out through the dependent packages