Skip to content

useMutation adds undefined to TResult of MutateFunction type #1111

@Haaxor1689

Description

@Haaxor1689

Describe the bug

useMutation changes the return type of provided promise by adding undefined to it.

To Reproduce

const apiCall = () => new Promise<string>(resolve => resolve());

const useExample = async () => {
	const [mutateCall] = useMutation(apiCall);
	const response = await apiCall(); // string
	const mutateR = await mutateCall(); // string | undefined
};

Wrapping a function in useMutation adds a undefined to it's returned promise

Expected behavior

The provided function's return type should not be changed.

Desktop (please complete the following information):

  • Version: 23

Additional context

I don't see any reason why this would be required. Together with #1077 this is making migration to this library pretty unnecessarily painful by imposing this opinionated 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