Skip to content

Conversation

@ledouxm
Copy link

@ledouxm ledouxm commented Feb 18, 2025

Hello !
I had an issue with the return type of the better-fetch client when using { throw: true } :

const api = createClient<AppRouter>({
  throw: true,
});


const api2 = createClient<AppRouter>({
  throw: false,
});

const resp1 = await api("/is-first-connection", {});
const resp2 = await api2("/is-first-connection", {});

type AreResponsesEqual = typeof resp1 extends typeof resp2 ? true : false;
//   ^? type AreResponsesEqual = true

So I've used function overloading to fix it.

If you think of a better way of achieving this, please let me know :)

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.

1 participant