Skip to content

Scheduling infrastructure for absolutely everyone.

refactor: Get rid of usages of Next.js private interfaces in our codebase (#23080)

Benny Joo881602cf1c4e
diff --git a/apps/web/app/_types.ts b/apps/web/app/_types.ts
index 30a4ce65793..8f73517ba86 100644
--- a/apps/web/app/_types.ts
+++ b/apps/web/app/_types.ts
@@ -13,5 +13,5 @@ export type PageProps = {
export type LayoutProps = { params: Promise<Params>; children: React.ReactElement };
-export { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
-export { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
+export type ReadonlyHeaders = Awaited<ReturnType<typeof import("next/headers").headers>>;
+export type ReadonlyRequestCookies = Awaited<ReturnType<typeof import("next/headers").cookies>>;
diff --git a/apps/web/lib/buildLegacyCtx.tsx b/apps/web/lib/buildLegacyCtx.tsx
index f26f8a4e094..614393584cd 100644
--- a/apps/web/lib/buildLegacyCtx.tsx
+++ b/apps/web/lib/buildLegacyCtx.tsx
@@ -1,8 +1,7 @@
import type { SearchParams } from "app/_types";
import { type Params } from "app/_types";
+import type { ReadonlyHeaders, ReadonlyRequestCookies } from "app/_types";
import type { GetServerSidePropsContext, NextApiRequest } from "next";
-import { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
-import { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
const createProxifiedObject = (object: Record<string, string>) =>
new Proxy(object, {
diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx
index 5ae26bac6a2..8b34a72e099 100644
--- a/apps/web/pages/_app.tsx
+++ b/apps/web/pages/_app.tsx
@@ -1,6 +1,6 @@
import type { IncomingMessage } from "http";
+import type { NextPageContext } from "next";
import { SessionProvider } from "next-auth/react";
-import type { AppContextType } from "next/dist/shared/lib/utils";
import React from "react";
import CacheProvider from "react-inlinesvg/provider";
@@ -32,8 +32,8 @@ declare global {
}
}
-MyApp.getInitialProps = async (ctx: AppContextType) => {
- const { req } = ctx.ctx;
+MyApp.getInitialProps = async ({ ctx }: { ctx: NextPageContext }) => {
+ const { req } = ctx;
let newLocale = "en";
diff --git a/packages/features/auth/lib/getLocale.ts b/packages/features/auth/lib/getLocale.ts
index 1df0780a110..4f5bbe9cec5 100644
--- a/packages/features/auth/lib/getLocale.ts
+++ b/packages/features/auth/lib/getLocale.ts
@@ -2,11 +2,12 @@ import { parse } from "accept-language-parser";
import { lookup } from "bcp-47-match";
import type { GetTokenParams } from "next-auth/jwt";
import { getToken } from "next-auth/jwt";
-import { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
-import { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
import { i18n } from "@calcom/config/next-i18next.config";
+type ReadonlyHeaders = Awaited<ReturnType<typeof import("next/headers").headers>>;
+type ReadonlyRequestCookies = Awaited<ReturnType<typeof import("next/headers").cookies>>;
+
/**
* This is a slimmed down version of the `getServerSession` function from
* `next-auth`.