Next 13 build giving strange error: Property ‘MyApp’ is incompatible with index signature

I’m using Next.js version 13.5.5 and when I run npm run build It gives me this error:

./build/types/app/layout.ts:8:13
Type error: Type 'OmitWithTag<typeof import("D:/nodeprogs/br-books-frontend/src/app/layout"), "metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | "dynamicParams" | "fetchCache" | "preferredRegion" | "runtime" | "maxDuration" | "generateMetadata", "">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'MyApp' is incompatible with index signature.
    Type '({ children }: { children: React.ReactNode; }) => React.JSX.Element' is not assignable to type 'never'.

   6 |
   7 | // Check that the entry is a valid entry
>  8 | checkFields<Diff<{
     |             ^
   9 |   default: Function
  10 |   config?: {}
  11 |   generateStaticParams?: Function

Here’s some relevant code:

export const MyApp = ({ children }: { children: React.ReactNode }) => {
  const theme = ThemeSettings();

  // const customizer = useSelector((state: AppState) => state.customizer);

  return (
    <>
    <SpeedInsights />
      <NextTopLoader color="#ee7b48" />
      {/* <NextAppDirEmotionCacheProvider options={{ key: "flexy" }}> */}
        <ThemeProvider theme={theme}>
            {/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
            <CssBaseline />
            {children}
        </ThemeProvider>
      {/* </NextAppDirEmotionCacheProvider> */}
    </>
  );
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const [loading, setLoading] = React.useState(true);
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <Provider store={store}>
        <ToastContainer
          position="top-right"
          autoClose={3000}
          hideProgressBar={false}
          newestOnTop={false}
          closeOnClick
          rtl={false}
          pauseOnFocusLoss
          draggable
          pauseOnHover
          theme="light"
        />
          {loading ? (
            // eslint-disable-next-line react/no-children-prop
            <MyApp children={children as React.ReactNode} />
          ) : (
            <Box
              sx={{
                display: "flex",
                justifyContent: "center",
                alignItems: "center",
                width: "100%",
                height: "100vh",
              }}
            >
              <CircularProgress color="primary" />
            </Box>
          )}
        </Provider>
      </body>
    </html>
  );
}

It’s strange because the error comes from the build folder and I have no idea what’s causing this issue. Can anyone help me fix this problem? I don’t know why it says React.JSX element is not assignable to type ‘never’. Thanks.