MrReinvent
MrReinvent
BABetter Auth
Created by MrReinvent on 2/25/2025 in #help
The inferred type of 'authClient' cannot be named without a reference to '.pnpm/@better-fetch+fetch@
This is a known issue (see better-auth issue #1391) Your choices (if you don't want to tweak your tsconfig or wait until this is fixed upstream) are usually to install the inner types in the consuming package, or export your own types from your internal package and re-use it in the consumer. Neither are ideal, but I went with the second. For example, In my @repo/auth package, I export the Auth Client type: - https://github.com/nktnet1/rt-stack/blob/c9e2c654d5014389c82ed07b34b7dc316452f331/packages/auth/src/client.ts#L7 The type is then explicitly set when instantiating the auth client in my web application: - https://github.com/nktnet1/rt-stack/blob/c9e2c654d5014389c82ed07b34b7dc316452f331/apps/web/src/clients/authClient.ts#L4 --- This is not unique to better-auth - for example, next-auth has a similar thread, with a workaround: - https://github.com/nextauthjs/next-auth/discussions/9950#discussioncomment-9135791 whereby you tweak the tsconfig.json compilerOptions -> declaration:
{
"compilerOptions": {
"declaration": false,
}
}
{
"compilerOptions": {
"declaration": false,
}
}
although I would personally advise against this (see the linked thread for details).
4 replies