Skip to content

Commit

Permalink
fix: Fix all TS warnings (fix-tsWarnings) (#12139)
Browse files Browse the repository at this point in the history
Co-authored-by: gitstart-calcom <[email protected]>
Co-authored-by: GitStart-Cal.com <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
  • Loading branch information
4 people authored Jan 4, 2024
1 parent 574a4a8 commit 6a13258
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 80 deletions.
4 changes: 2 additions & 2 deletions apps/web/lib/withNonce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { GetServerSideProps } from "next";

import { csp } from "@lib/csp";

export type WithNonceProps<T extends Record<string, any>> = T & {
export type WithNonceProps<T extends Record<string, unknown>> = T & {
nonce?: string;
};

Expand All @@ -11,7 +11,7 @@ export type WithNonceProps<T extends Record<string, any>> = T & {
* Note that if the Components are not adding any script tag then this is not needed. Even in absence of this, Document.getInitialProps would be able to generate nonce itself which it needs to add script tags common to all pages
* There is no harm in wrapping a `getServerSideProps` fn with this even if it doesn't add any script tag.
*/
export default function withNonce<T extends Record<string, any>>(
export default function withNonce<T extends Record<string, unknown>>(
getServerSideProps: GetServerSideProps<T>
): GetServerSideProps<WithNonceProps<T>> {
return async (context) => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ MyApp.getInitialProps = async (ctx: AppContextType) => {

if (req) {
const { getLocale } = await import("@calcom/features/auth/lib/getLocale");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
newLocale = await getLocale(req as IncomingMessage & { cookies: Record<string, any> });
} else if (typeof window !== "undefined" && window.calNewLocale) {
newLocale = window.calNewLocale;
Expand Down
3 changes: 2 additions & 1 deletion apps/web/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class MyDocument extends Document<Props> {

const newLocale =
ctx.req && getLocaleModule
? await getLocaleModule.getLocale(ctx.req as IncomingMessage & { cookies: Record<string, any> })
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
await getLocaleModule.getLocale(ctx.req as IncomingMessage & { cookies: Record<string, any> })
: "en";

const asPath = ctx.asPath || "";
Expand Down
1 change: 1 addition & 0 deletions apps/web/pages/auth/oauth2/authorize.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
import { useState, useEffect } from "react";
Expand Down
7 changes: 1 addition & 6 deletions apps/web/pages/event-types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ const EventTypesPage = () => {
const searchParams = useCompatSearchParams();
const { open } = useIntercom();
const { data: user } = useMeQuery();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [showProfileBanner, setShowProfileBanner] = useState(false);
const orgBranding = useOrgBranding();
const routerQuery = useRouterQuery();
Expand All @@ -919,12 +920,6 @@ const EventTypesPage = () => {
staleTime: 1 * 60 * 60 * 1000,
});

function closeBanner() {
setShowProfileBanner(false);
document.cookie = `calcom-profile-banner=1;max-age=${60 * 60 * 24 * 90}`; // 3 months
showToast(t("we_wont_show_again"), "success");
}

useEffect(() => {
if (searchParams?.get("openIntercom") === "true") {
open();
Expand Down
42 changes: 15 additions & 27 deletions apps/web/playwright/payment-apps.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ test.describe("Payment app", () => {
const user = await users.create();
await user.apiLogin();
const paymentEvent = user.eventTypes.find((item) => item.slug === "paid");
if (!paymentEvent) {
throw new Error("No payment event found");
}
expect(paymentEvent).not.toBeNull();
await prisma.credential.create({
data: {
type: "alby_payment",
Expand All @@ -30,15 +28,15 @@ test.describe("Payment app", () => {
},
});

await page.goto(`event-types/${paymentEvent.id}?tabName=apps`);
await page.goto(`event-types/${paymentEvent?.id}?tabName=apps`);

await page.locator("#event-type-form").getByRole("switch").click();
await page.getByPlaceholder("Price").click();
await page.getByPlaceholder("Price").fill("200");
await page.getByText("SatoshissatsCurrencyBTCPayment optionCollect payment on booking").click();
await page.getByTestId("update-eventtype").click();

await page.goto(`${user.username}/${paymentEvent.slug}`);
await page.goto(`${user.username}/${paymentEvent?.slug}`);

// expect 200 sats to be displayed in page
expect(await page.locator("text=200 sats").first()).toBeTruthy();
Expand All @@ -55,9 +53,7 @@ test.describe("Payment app", () => {
const user = await users.create();
await user.apiLogin();
const paymentEvent = user.eventTypes.find((item) => item.slug === "paid");
if (!paymentEvent) {
throw new Error("No payment event found");
}
expect(paymentEvent).not.toBeNull();
await prisma.credential.create({
data: {
type: "stripe_payment",
Expand All @@ -75,7 +71,7 @@ test.describe("Payment app", () => {
},
});

await page.goto(`event-types/${paymentEvent.id}?tabName=apps`);
await page.goto(`event-types/${paymentEvent?.id}?tabName=apps`);
await page.locator("#event-type-form").getByRole("switch").click();
await page.getByTestId("stripe-currency-select").click();
await page.getByTestId("select-option-usd").click();
Expand All @@ -84,7 +80,7 @@ test.describe("Payment app", () => {
await page.getByTestId("stripe-price-input").fill("350");
await page.getByTestId("update-eventtype").click();

await page.goto(`${user.username}/${paymentEvent.slug}`);
await page.goto(`${user.username}/${paymentEvent?.slug}`);

// expect 200 sats to be displayed in page
expect(await page.locator("text=350").first()).toBeTruthy();
Expand All @@ -101,9 +97,7 @@ test.describe("Payment app", () => {
const user = await users.create();
await user.apiLogin();
const paymentEvent = user.eventTypes.find((item) => item.slug === "paid");
if (!paymentEvent) {
throw new Error("No payment event found");
}
expect(paymentEvent).not.toBeNull();
await prisma.credential.create({
data: {
type: "paypal_payment",
Expand All @@ -116,7 +110,7 @@ test.describe("Payment app", () => {
},
});

await page.goto(`event-types/${paymentEvent.id}?tabName=apps`);
await page.goto(`event-types/${paymentEvent?.id}?tabName=apps`);

await page.locator("#event-type-form").getByRole("switch").click();

Expand All @@ -131,7 +125,7 @@ test.describe("Payment app", () => {
await page.getByText("$MXNCurrencyMexican pesoPayment option").click();
await page.getByTestId("update-eventtype").click();

await page.goto(`${user.username}/${paymentEvent.slug}`);
await page.goto(`${user.username}/${paymentEvent?.slug}`);

// expect 150 to be displayed in page
expect(await page.locator("text=MX$150.00").first()).toBeTruthy();
Expand All @@ -149,9 +143,7 @@ test.describe("Payment app", () => {
const user = await users.create();
await user.apiLogin();
const paymentEvent = user.eventTypes.find((item) => item.slug === "paid");
if (!paymentEvent) {
throw new Error("No payment event found");
}
expect(paymentEvent).not.toBeNull();
await prisma.credential.create({
data: {
type: "alby_payment",
Expand All @@ -160,7 +152,7 @@ test.describe("Payment app", () => {
},
});

await page.goto(`event-types/${paymentEvent.id}?tabName=apps`);
await page.goto(`event-types/${paymentEvent?.id}?tabName=apps`);

await page.locator("#event-type-form").getByRole("switch").click();

Expand All @@ -177,9 +169,7 @@ test.describe("Payment app", () => {
const user = await users.create();
await user.apiLogin();
const paymentEvent = user.eventTypes.find((item) => item.slug === "paid");
if (!paymentEvent) {
throw new Error("No payment event found");
}
expect(paymentEvent).not.toBeNull();
await prisma.credential.create({
data: {
type: "paypal_payment",
Expand All @@ -188,7 +178,7 @@ test.describe("Payment app", () => {
},
});

await page.goto(`event-types/${paymentEvent.id}?tabName=apps`);
await page.goto(`event-types/${paymentEvent?.id}?tabName=apps`);

await page.locator("#event-type-form").getByRole("switch").click();

Expand All @@ -211,9 +201,7 @@ test.describe("Payment app", () => {
await user.apiLogin();
// Any event should work here
const paymentEvent = user.eventTypes.find((item) => item.slug === "paid");
if (!paymentEvent) {
throw new Error("No payment event found");
}
expect(paymentEvent).not.toBeNull();

await prisma.credential.create({
data: {
Expand All @@ -225,7 +213,7 @@ test.describe("Payment app", () => {
},
});

await page.goto(`event-types/${paymentEvent.id}?tabName=apps`);
await page.goto(`event-types/${paymentEvent?.id}?tabName=apps`);

await page.locator("#event-type-form").getByRole("switch").click();
// make sure Tracking ID is displayed
Expand Down
1 change: 1 addition & 0 deletions apps/web/playwright/reschedule.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ test.describe("Reschedule Tests", async () => {
let firstOfNextMonth = dayjs().add(1, "month").startOf("month");

// find first available slot of next month (available monday-friday)
// eslint-disable-next-line playwright/no-conditional-in-test
while (firstOfNextMonth.day() < 1 || firstOfNextMonth.day() > 5) {
firstOfNextMonth = firstOfNextMonth.add(1, "day");
}
Expand Down
5 changes: 1 addition & 4 deletions apps/web/test/lib/handleChildrenEventTypes.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";

import type { EventType } from "@prisma/client";
Expand Down Expand Up @@ -97,7 +98,6 @@ describe("handleChildrenEventTypes", () => {
it("Adds new users", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line
const {
schedulingType,
id,
Expand Down Expand Up @@ -141,7 +141,6 @@ describe("handleChildrenEventTypes", () => {
it("Updates old users", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line
const {
schedulingType,
id,
Expand Down Expand Up @@ -237,7 +236,6 @@ describe("handleChildrenEventTypes", () => {
it("Deletes existent event types for new users added", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line
const {
schedulingType,
id,
Expand Down Expand Up @@ -282,7 +280,6 @@ describe("handleChildrenEventTypes", () => {
it("Deletes existent event types for old users updated", async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line
const {
schedulingType,
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions packages/app-store/_utils/oauth/refreshOAuthTokens.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/app-store/basecamp3/lib/CalendarService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
1 change: 1 addition & 0 deletions packages/app-store/basecamp3/trpc/_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 5 additions & 1 deletion packages/app-store/basecamp3/trpc/projectMutation.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
setAppData("paymentOption", paymentOptions[0].value);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand Down
19 changes: 3 additions & 16 deletions packages/app-store/paypal/lib/PaymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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> {
Expand All @@ -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);
}

Expand Down
Loading

0 comments on commit 6a13258

Please sign in to comment.