fix: add explicit type annotation to CalComAdapter function (#22230)

* fix: add explicit type annotation to CalComAdapter function

Resolves TS7056 error where inferred type exceeded maximum length
the compiler will serialize. Added custom CalComAdapterType type
annotation to provide explicit typing while preserving existing
functionality of the authentication adapter.

The custom type annotation matches the actual implementation structure
and resolves the TypeScript compilation error without breaking the
existing NextAuth adapter functionality.

Co-Authored-By: [email protected] <[email protected]>

* fix: replace any types with proper NextAuth Adapter typing

- Import Awaitable type from next-auth for proper async typing
- Define CalComAdapter type using Cal.com's actual Prisma types
- Remove all any types following TypeScript best practices
- Maintain compatibility with NextAuth's expected interface
- Resolves TS7056 compilation error with explicit typing

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
This commit is contained in:
devin-ai-integration[bot]and[email protected] authored and GitHub committed 2025-07-03 11:37:15 +01:00
1 parent d04c7f58a1
commit d23d68bf2d
1 file changed
+22 -1
@@ -1,12 +1,33 @@
import type { Account, IdentityProvider, Prisma, User, VerificationToken } from "@prisma/client";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
import type { Awaitable } from "next-auth";
import type { PrismaClient } from "@calcom/prisma";
import { identityProviderNameMap } from "./identityProviderNameMap";
type CalComAdapter = {
createUser: (data: Prisma.UserCreateInput) => Awaitable<User>;
getUser: (id: string | number) => Awaitable<User | null>;
getUserByEmail: (email: User["email"]) => Awaitable<User | null>;
getUserByAccount: (provider_providerAccountId: {
providerAccountId: Account["providerAccountId"];
provider: User["identityProvider"];
}) => Awaitable<User | null>;
updateUser: (data: Prisma.UserUncheckedCreateInput) => Awaitable<User>;
deleteUser: (id: User["id"]) => Awaitable<User>;
createVerificationToken: (data: VerificationToken) => Awaitable<Omit<VerificationToken, "id">>;
useVerificationToken: (
identifier_token: Prisma.VerificationTokenIdentifierTokenCompoundUniqueInput
) => Awaitable<Omit<VerificationToken, "id"> | null>;
linkAccount: (data: Prisma.AccountCreateInput) => Awaitable<Account>;
unlinkAccount: (
provider_providerAccountId: Prisma.AccountProviderProviderAccountIdCompoundUniqueInput
) => Awaitable<Account>;
};
/** @return { import("next-auth/adapters").Adapter } */
export default function CalComAdapter(prismaClient: PrismaClient) {
export default function CalComAdapter(prismaClient: PrismaClient): CalComAdapter {
return {
createUser: (data: Prisma.UserCreateInput) => prismaClient.user.create({ data }),
getUser: (id: string | number) =>