Some organization plugin types are not inferred when used from within withCloudflare wrapper.
(Workaround 1 - without wrapper)
(Workaround 2 - with wrapper]
Configuration used:
return betterAuth({
...withCloudflare(
{
autoDetectIpAddress: true,
geolocationTracking: true,
cf: cf || {},
postgres: {
db,
options: {
usePlural: true,
debugLogs: false,
},
},
kv: env?.KV as KVNamespace,
},
{
plugins: [
admin(),
organization(),
apiKey(),
lastLoginMethod(),
],
}
)});
Logs:
➜ npm run build
> build
> npx tsc --noEmit
src/index.ts:100:25 - error TS2339: Property 'activeOrganizationId' does not exist on type '{ id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }'.
100 if (session.session.activeOrganizationId) {
~~~~~~~~~~~~~~~~~~~~
src/index.ts:102:57 - error TS2339: Property 'getActiveMemberRole' does not exist on type 'InferAPI<{ ok: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({ body?: undefined; } & { method?: "GET" | undefined; } & { query?: Record<string, any> | undefined; } & { params?: Record<string, any> | undefined; } & { ...; } & { ...; } & { ...; } & { ...; }) | undefined): ...'.
102 const { role: orgRoleStr } = await auth.api.getActiveMemberRole({ headers: reqHeaders });
~~~~~~~~~~~~~~~~~~~
Some organization plugin types are not inferred when used from within
withCloudflarewrapper.(Workaround 1 - without wrapper)
(Workaround 2 - with wrapper]
Configuration used:
Logs: