fix: Some recently discovered type errors breaking build (not sure why undetected before) (#18432)

This commit is contained in:
Alex van Andel
2024-12-31 13:50:43 +00:00
committed by GitHub
parent 557bd8bf25
commit 890fc92148
10 changed files with 19 additions and 21 deletions
+10 -7
View File
@@ -13,6 +13,9 @@ export function createMockNextJsRequest(...args: Parameters<typeof createMocks>)
return createMocks<CustomNextApiRequest, CustomNextApiResponse>(...args);
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
const noop = () => {};
vi.mock("next/navigation", () => ({
redirect: vi.fn(),
notFound: vi.fn(),
@@ -86,7 +89,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);
expect(redirect).toHaveBeenCalledWith("/reschedule/embed?layout=week_view&embed=namespace1");
});
@@ -105,7 +108,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);
expect(redirect).toHaveBeenCalledWith(
"/reschedule/embed?redirectParam=1&layout=week_view&embed=namespace1"
@@ -126,7 +129,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "",
},
})
).catch(() => {});
).catch(noop);
expect(redirect).toHaveBeenCalledWith("/reschedule/embed?redirectParam=1&layout=week_view&embed=");
});
@@ -147,7 +150,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);
expect(redirect).toHaveBeenCalledWith(
"https://calcom.cal.local/owner/embed?layout=week_view&embed=namespace1"
@@ -168,7 +171,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);
expect(redirect).toHaveBeenCalledWith(
"http://calcom.cal.local/owner/embed?layout=week_view&embed=namespace1"
@@ -189,7 +192,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);
expect(redirect).toHaveBeenCalledWith(
"/calcom.cal.local/owner/embed?layout=week_view&embed=namespace1"
@@ -239,7 +242,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "",
},
})
).catch(() => {});
).catch(noop);
expect(notFound).toHaveBeenCalled();
});
+1 -1
View File
@@ -33,7 +33,7 @@ const createI18nInstance = async (locale: string, ns: string) => {
return _i18n;
};
const getTranslationWithCache = async (locale: string, ns: string = "common") => {
const getTranslationWithCache = async (locale: string, ns = "common") => {
const localeWithFallback = locale ?? "en";
const i18n = await createI18nInstance(localeWithFallback, ns);
return i18n.getFixedT(localeWithFallback, ns);
+1 -1
View File
@@ -20,7 +20,7 @@ const inputSchema = z.object({
cardKeys: z.array(z.string()),
});
export async function handler(request: Request) {
async function handler(request: Request) {
const headersList = headers();
const requestBody = await request.json();
+1 -1
View File
@@ -1,4 +1,4 @@
import { PageProps } from "app/_types";
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { redirect } from "next/navigation";
@@ -1,6 +1,4 @@
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
@@ -1,6 +1,4 @@
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { getServerSideProps } from "@lib/team/[slug]/[type]/getServerSideProps";
@@ -1,7 +1,4 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
+1
View File
@@ -76,6 +76,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<script
nonce={nonce}
id="headScript"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `
window.calNewLocale = "${locale}";
@@ -1,3 +1,4 @@
import type { EmbedProps } from "app/WithEmbedSSR";
import type { GetServerSidePropsContext } from "next";
import { z } from "zod";
@@ -12,7 +13,6 @@ import { RedirectType } from "@calcom/prisma/enums";
import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
import type { EmbedProps } from "app/WithEmbedSSR";
export type PageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;
@@ -14,7 +14,7 @@ import { Icon, TableNew, TableBody, TableCell, TableHead, TableHeader, TableRow
import { usePersistentColumnResizing } from "../lib/resizing";
export interface DataTableProps<TData, TValue> {
export type DataTableProps<TData, TValue> = {
table: ReactTableType<TData>;
tableContainerRef: React.RefObject<HTMLDivElement>;
isPending?: boolean;
@@ -26,7 +26,7 @@ export interface DataTableProps<TData, TValue> {
children?: React.ReactNode;
identifier?: string;
enableColumnResizing?: boolean;
}
};
export function DataTable<TData, TValue>({
table,
@@ -89,7 +89,8 @@ export function DataTable<TData, TValue>({
usePersistentColumnResizing({
enabled: Boolean(enableColumnResizing),
table,
identifier,
// TODO: Figure out why 'identifier' somehow types to string | null
identifier: identifier || undefined,
});
return (