import { type FunctionComponent } from "react"; type ImportFn = () => Promise<{ default: FunctionComponent; }>; type Preloader = { preload: ImportFn; }; /** * A component type that supports lazy loading and preloading. */ export type LazyComponent = Props extends undefined ? FunctionComponent & Preloader : FunctionComponent & Preloader; type DefaultExport> = Awaited>["default"]; type InferProps> = Parameters>[0]; /** * Wraps a dynamic import function to create a lazy-loaded component with preloading capabilities. * * @remarks * This utility extends React's `lazy` by attaching the original import function as a `preload` property. * This allows the router to fetch the component code before rendering it, improving perceived performance. * * @typeParam Fn - The dynamic import function type. * @param importStatement - The function that imports the component. * @returns A `LazyComponent` that can be rendered and preloaded. * * @example * ```ts * const UserProfile = lazy(() => import('./UserProfile')); * // Later... * UserProfile.preload(); // Start fetching code * ``` */ export declare function lazy>(importStatement: Fn): LazyComponent>; export {};