أنا أعمل على مشروع بواسطة NextJS باستخدام TypeScript
لدي مشكلة في هذا السطر :
const Layout = layouts[Component.layout] || ((children) => <>{children}</>)
هذا هو الخطأ الذي ظهر لي
var Component: NextComponentType<NextPageContext, any, {}>
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ L1: FC<{}>; L2: FC<{}>; }'.ts(7053)
وهذا هو الكود الكامل
// App Style
import '../src/css/app.css'
import { AnimatePresence } from 'framer-motion'
import React from "react";
import type { AppProps } from 'next/app'
import AuthLayout from "../layouts/AuthLayout";
import ContentLayout from "../layouts/ContentLayout";
function MyApp({ Component, pageProps }: AppProps) {
const layouts = {
L1: AuthLayout,
L2: ContentLayout,
};
const Layout = layouts[Component.layout] || ((children) => <>{children}</>)
return (
<Layout>
<AnimatePresence exitBeforeEnter>
<Component {...pageProps} />
</AnimatePresence>
</Layout>
);
}
export default MyApp