Skip to content

Conversation

@gmaclennan
Copy link
Member

The mutation hooks currently do this:

	return status === 'error'
		? { error, mutate, reset, status }
		: { error: null, mutate, reset, status }

To force typescript into returning the correct distributive type.

This is a follow-up to this comment about better ways to do this.

This is one solution, implementing a pick function (similar to what the current object spread and object create is doing) that correctly maintains the types. Adds Simplify from type-fest so that the return types are more readable for the library consumer.

Leaving this here as an idea, not fully implemented, feel free to ignore or finish the implementation.

@gmaclennan gmaclennan self-assigned this Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants