Skip to content

Specifying placeholder or initial data should give data prop a different type #2288

Closed
@midzdotdev

Description

@midzdotdev

Describe the bug
This bug is solely for the benefit of using react-query with TypeScript.

When specifying the initialData option, I don't think the data prop should be unioned with undefined. Then whenever you want to use the data of the returned object, you have to apply the non-null assertion operator (!) to use it's value.

I assume this also applies to placeholderData but I've not used it so not 100% here.

To Reproduce
Make a call to the useQuery hook with specifying either initialData or placeholderData.

Expected behavior
When either initialData or placeholderData is specified, then data is not unioned with undefined.

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