Files
cal.diy/apps/web/pages/_app.tsx
T
Robert Harrison 54343aa685
Create PR containing updated CHANGELOG.md and release packages to NPM once PR is merged / Release (push) Canceled after 0s
Run i18n AI automation / Run i18n (push) Canceled after 0s
Next.js Bundle Analysis / analyze (push) Canceled after 0s
fix: restore @ts-expect-error for CacheProvider type mismatch (#30171)
* fix: restore @ts-expect-error for CacheProvider type mismatch

PR #30140 removed these comments assuming they were stale now that
the repo is on TypeScript 5. The comments were about the compiler
version, but the actual incompatibility is between react-inlinesvg/provider's
CacheProvider (typed to return a bare ReactNode) and this repo's pinned
@types/react@18.0.26, which requires JSX components to return Element | null.
ReactNode includes undefined, so the JSX usage fails type-checking.

Verified yarn build completes successfully with this restored.

Fixes #30170

* docs: explain the actual @ts-expect-error compatibility condition

Per @coderabbitai review on #30171: the old wording ("remove when
upgrading typescript to v5") was itself stale/misleading, since the
incompatibility is with the pinned @types/react version, not the
TypeScript compiler version. Documents the real condition instead.
2026-09-20 13:47:32 +05:30

58 lines
1.6 KiB
TypeScript

import type { IncomingMessage } from "node:http";
import type { NextPageContext } from "next";
import { SessionProvider } from "next-auth/react";
import React from "react";
import CacheProvider from "react-inlinesvg/provider";
import { WebPushProvider } from "@calcom/web/modules/notifications/components/WebPushContext";
import { trpc } from "@calcom/trpc/react";
import type { AppProps } from "@lib/app-providers";
import "../styles/globals.css";
function MyApp(props: AppProps) {
const { Component, pageProps } = props;
return (
<SessionProvider session={pageProps.session ?? undefined}>
<WebPushProvider>
{/* @ts-expect-error react-inlinesvg/provider is incompatible with @types/react@18.0.26. Remove when these types are compatible. */}
<CacheProvider>
{Component.PageWrapper ? <Component.PageWrapper {...props} /> : <Component {...pageProps} />}
</CacheProvider>
</WebPushProvider>
</SessionProvider>
);
}
declare global {
interface Window {
calNewLocale: string;
}
}
MyApp.getInitialProps = async ({ ctx }: { ctx: NextPageContext }) => {
const { req } = ctx;
let newLocale = "en";
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;
}
return {
pageProps: {
newLocale,
},
};
};
const WrappedMyApp = trpc.withTRPC(MyApp);
export default WrappedMyApp;