fix: Fix all TS warnings (fix-tsWarnings) (#12139)

Co-authored-by: gitstart-calcom <[email protected]>
Co-authored-by: GitStart-Cal.com <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-01-03 18:18:42 -07:00
1 parent 574a4a847d
commit 6a1325867e
22 files changed
+42 -80

No files matched your search

@@ -14,6 +14,7 @@ export type ParseRefreshTokenResponse<S extends z.ZodTypeAny> =
| z.infer<S>
| z.infer<typeof minimumTokenResponseSchema>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const parseRefreshTokenResponse = (response: any, schema: z.ZodTypeAny) => {
let refreshTokenResponse;
const credentialSyncingEnabled =
@@ -1,5 +1,6 @@
import { APP_CREDENTIAL_SHARING_ENABLED } from "@calcom/lib/constants";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const refreshOAuthTokens = async (refreshFunction: () => any, appSlug: string, userId: number | null) => {
// Check that app syncing is enabled and that the credential belongs to a user
if (APP_CREDENTIAL_SHARING_ENABLED && process.env.CALCOM_CREDENTIAL_SYNC_ENDPOINT && userId) {
@@ -18,9 +18,11 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
useEffect(() => {
setSelectedProject({
value: data?.projects.currentProject,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
label: data?.projects?.find((project: any) => project.id === data?.currentProject)?.name,
});
setProjects(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data?.projects?.map((project: any) => {
return {
value: project.id,
@@ -59,6 +59,7 @@ export default class BasecampCalendarService implements Calendar {
constructor(credential: CredentialPayload) {
this.integrationName = "basecamp3";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getAppKeysFromSlug("basecamp3").then(({ user_agent }: any) => {
this.userAgent = user_agent as string;
});
@@ -3,6 +3,7 @@ import { router } from "@calcom/trpc/server/trpc";
import { ZProjectMutationInputSchema } from "./projectMutation.schema";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const UNSTABLE_HANDLER_CACHE: any = {};
const appBasecamp3 = router({
@@ -16,6 +16,10 @@ interface ProjectMutationHandlerOptions {
input: TProjectMutationInputSchema;
}
interface IDock {
id: number;
name: string;
}
export const projectMutationHandler = async ({ ctx, input }: ProjectMutationHandlerOptions) => {
const { user_agent } = await getAppKeysFromSlug("basecamp3");
const { user, prisma } = ctx;
@@ -48,7 +52,7 @@ export const projectMutationHandler = async ({ ctx, input }: ProjectMutationHand
}
);
const scheduleJson = await scheduleResponse.json();
const scheduleId = scheduleJson.dock.find((dock: any) => dock.name === "schedule").id;
const scheduleId = scheduleJson.dock.find((dock: IDock) => dock.name === "schedule").id;
await prisma.credential.update({
where: { id: credential.id },
data: { key: { ...credentialKey, projectId: Number(projectId), scheduleId } },
@@ -56,6 +56,7 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
setAppData("paymentOption", paymentOptions[0].value);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
@@ -8,7 +8,6 @@ import { ErrorCode } from "@calcom/lib/errorCodes";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import prisma from "@calcom/prisma";
import type { CalendarEvent } from "@calcom/types/Calendar";
import type { IAbstractPaymentService } from "@calcom/types/PaymentService";
import { paymentOptionEnum } from "../zod";
@@ -179,10 +178,7 @@ export class PaymentService implements IAbstractPaymentService {
throw new Error("Paypal: Payment method could not be collected");
}
}
chargeCard(
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
bookingId: number
): Promise<Payment> {
chargeCard(): Promise<Payment> {
throw new Error("Method not implemented.");
}
getPaymentPaidStatus(): Promise<string> {
@@ -191,19 +187,10 @@ export class PaymentService implements IAbstractPaymentService {
getPaymentDetails(): Promise<Payment> {
throw new Error("Method not implemented.");
}
afterPayment(
event: CalendarEvent,
booking: {
user: { email: string | null; name: string | null; timeZone: string } | null;
id: number;
startTime: { toISOString: () => string };
uid: string;
},
paymentData: Payment
): Promise<void> {
afterPayment(): Promise<void> {
return Promise.resolve();
}
deletePayment(paymentId: number): Promise<boolean> {
deletePayment(): Promise<boolean> {
return Promise.resolve(false);
}
-18
View File
@@ -1,7 +1,6 @@
import { Prisma } from "@prisma/client";
import { getLocationGroupedOptions } from "@calcom/app-store/server";
import type { StripeData } from "@calcom/app-store/stripepayment/lib/server";
import { getEventTypeAppData } from "@calcom/app-store/utils";
import type { LocationObject } from "@calcom/core/location";
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
@@ -9,7 +8,6 @@ import { parseBookingLimit, parseDurationLimit, parseRecurringEvent } from "@cal
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { getTranslation } from "@calcom/lib/server/i18n";
import type { PrismaClient } from "@calcom/prisma";
import type { Credential } from "@calcom/prisma/client";
import { SchedulingType, MembershipRole } from "@calcom/prisma/enums";
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
@@ -397,19 +395,3 @@ export default async function getEventTypeById({
};
return finalObj;
}
const getStripeCurrency = (stripeMetadata: { currency: string }, credentials: Credential[]) => {
// Favor the currency from the metadata as EventType.currency was not always set and should be deprecated
if (stripeMetadata.currency) {
return stripeMetadata.currency;
}
// Legacy support for EventType.currency
const stripeCredential = credentials.find((integration) => integration.type === "stripe_payment");
if (stripeCredential) {
return (stripeCredential.key as unknown as StripeData)?.default_currency || "usd";
}
// Fallback to USD but should not happen
return "usd";
};
-2
View File
@@ -2,8 +2,6 @@ import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
const ROLES_WITH_EDIT_PERMISSION = [MembershipRole.ADMIN, MembershipRole.OWNER] as MembershipRole[];
type InputOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
+1
View File
@@ -97,6 +97,7 @@ export async function getBooking(bookingId: number) {
}),
organizer: {
email: user.email,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
name: user.name!,
timeZone: user.timeZone,
timeFormat: getTimeFormatStringFromUserTimeFormat(user.timeFormat),
@@ -51,7 +51,6 @@ export const integrationsHandler = async ({ ctx, input }: IntegrationsOptions) =
extendsFeature,
teamId,
sortByMostPopular,
categories,
appId,
} = input;
let credentials = await getUsersCredentials(user.id);
@@ -187,7 +187,7 @@ export const listTeamAvailabilityHandler = async ({ ctx, input }: GetOptions) =>
let nextCursor: typeof cursor | undefined = undefined;
if (teamMembers && teamMembers.length > limit) {
const nextItem = teamMembers.pop();
nextCursor = nextItem!.id;
nextCursor = nextItem?.id;
}
const dateFrom = dayjs(input.startDate).tz(input.loggedInUsersTz).subtract(1, "day");
@@ -14,7 +14,7 @@ type OAuthRouterHandlerCache = {
const UNSTABLE_HANDLER_CACHE: OAuthRouterHandlerCache = {};
export const oAuthRouter = router({
getClient: authedProcedure.input(ZGetClientInputSchema).query(async ({ ctx, input }) => {
getClient: authedProcedure.input(ZGetClientInputSchema).query(async ({ input }) => {
if (!UNSTABLE_HANDLER_CACHE.getClient) {
UNSTABLE_HANDLER_CACHE.getClient = await import("./getClient.handler").then(
(mod) => mod.getClientHandler