Skip to content

RTK Query data and error not narrowed when exactOptionalPropertyTypes is enabled #5086

@chirophobic

Description

@chirophobic

When the TypeScript compiler option exactOptionalPropertyTypes is enabled, RTK Query hook results don’t narrow data (and similarly error) after status flag checks. For example, inside an if (result.isSuccess) block, result.data still has the type T | undefined instead of narrowing to T. With the flag disabled, narrowing behaves as expected.

Image

Reproduction
https://github.com/chirophobic/rtkquery-exact-optional-property-types-

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