Skip to content

Since PR #4393, success response types can no longer be resolved without explicit status/ok checks #4590

@baseballyama

Description

@baseballyama

PR #4393 improved the ability to get accurate types for specific status codes. While this is a great improvement on its own, it is causing an issue in my project.

In my project, we centrally manage 4xx and 5xx errors using a customized fetch function. Our design allows individual UI components to handle only the success cases. Previously, this meant our UI components were type-safe without needing to explicitly check the response code.

However, since v4.10.0 (where #4393 was released), we can no longer resolve the types without checking status or ok in each UI component. As a result, we are forced to add these checks to every single API call site. This negatively affects the codebase by reducing readability (due to increased boilerplate) and increasing the bundle size.

Is there a way to maintain type safety without manually checking status or code, just as we were able to do before? Any advice would be appreciated.

Originally posted by @baseballyama in #4575

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions