import { FC, lazy } from "react"; export const lazify = >(fn: () => Promise): T => { return lazy(async () => { const result = await fn(); return { default: result, }; }) as any; }; // export const lazify = < // MAPS extends { // [NAME in string]: () => Promise>; // } // >( // maps: MAPS // ) => { // type KEYS = keyof MAPS; // const result: any = {}; // for (const [k, v] of Object.entries(maps)) { // result[k] = single_lazy(v); // } // return result as { [K in KEYS]: Awaited> }; // };