Skip to content

Commit 881602c

Browse files
authored
refactor: Get rid of usages of Next.js private interfaces in our codebase (calcom#23080)
* chore: do not use nextjs private interfaces * fix type check * fix * fix * refactor
1 parent 4c01f17 commit 881602c

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

apps/web/app/_types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export type PageProps = {
1313

1414
export type LayoutProps = { params: Promise<Params>; children: React.ReactElement };
1515

16-
export { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
17-
export { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
16+
export type ReadonlyHeaders = Awaited<ReturnType<typeof import("next/headers").headers>>;
17+
export type ReadonlyRequestCookies = Awaited<ReturnType<typeof import("next/headers").cookies>>;

apps/web/lib/buildLegacyCtx.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { SearchParams } from "app/_types";
22
import { type Params } from "app/_types";
3+
import type { ReadonlyHeaders, ReadonlyRequestCookies } from "app/_types";
34
import type { GetServerSidePropsContext, NextApiRequest } from "next";
4-
import { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
5-
import { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
65

76
const createProxifiedObject = (object: Record<string, string>) =>
87
new Proxy(object, {

apps/web/pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IncomingMessage } from "http";
2+
import type { NextPageContext } from "next";
23
import { SessionProvider } from "next-auth/react";
3-
import type { AppContextType } from "next/dist/shared/lib/utils";
44
import React from "react";
55
import CacheProvider from "react-inlinesvg/provider";
66

@@ -32,8 +32,8 @@ declare global {
3232
}
3333
}
3434

35-
MyApp.getInitialProps = async (ctx: AppContextType) => {
36-
const { req } = ctx.ctx;
35+
MyApp.getInitialProps = async ({ ctx }: { ctx: NextPageContext }) => {
36+
const { req } = ctx;
3737

3838
let newLocale = "en";
3939

packages/features/auth/lib/getLocale.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { parse } from "accept-language-parser";
22
import { lookup } from "bcp-47-match";
33
import type { GetTokenParams } from "next-auth/jwt";
44
import { getToken } from "next-auth/jwt";
5-
import { type ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
6-
import { type ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
75

86
import { i18n } from "@calcom/config/next-i18next.config";
97

8+
type ReadonlyHeaders = Awaited<ReturnType<typeof import("next/headers").headers>>;
9+
type ReadonlyRequestCookies = Awaited<ReturnType<typeof import("next/headers").cookies>>;
10+
1011
/**
1112
* This is a slimmed down version of the `getServerSession` function from
1213
* `next-auth`.

0 commit comments

Comments
 (0)