import { Api, DefaultMethodMap } from '../api'; import { PromisifyFuncReturnType } from './types'; export type ProxyMapRemoteApi< RemoteMethodMap extends DefaultMethodMap > = { [methodName in keyof RemoteMethodMap]: PromisifyFuncReturnType }; export function proxyMapRemote< RemoteMethodMap extends DefaultMethodMap, >(api: Api): ProxyMapRemoteApi { return new Proxy({}, { get(target, p, receiver: any) { return (...args: any) => api.call(p as any, ...args); } }) as any; }