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

+2 -2
View File
@@ -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;
};
@@ -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) => {
+1
View File
@@ -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;
+2 -1
View File
@@ -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 || "";
+1
View File
@@ -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";
+1 -6
View File
@@ -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();
@@ -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();
+15 -27
View File
@@ -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",
@@ -30,7 +28,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.getByPlaceholder("Price").click();
@@ -38,7 +36,7 @@ test.describe("Payment app", () => {
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();
@@ -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",
@@ -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();
@@ -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();
@@ -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",
@@ -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();
@@ -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();
@@ -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",
@@ -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();
@@ -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",
@@ -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();
@@ -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: {
@@ -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
+1
View File
@@ -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");
}
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import prismaMock from "../../../../tests/libs/__mocks__/prismaMock";
import type { EventType } from "@prisma/client";
@@ -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,
@@ -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,
@@ -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,
@@ -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,