async-call-rpc

A lightweight JSON RPC client & server

Home > async-call-rpc > AsyncVersionOf

AsyncVersionOf type

Make all functions in T becomes an async function and filter non-Functions out.

Signature:

export type AsyncVersionOf<T> = T extends Record<keyof T, (...args: any) => PromiseLike<any>> ? 'then' extends keyof T ? Omit<Readonly<T>, 'then'> : T : _AsyncVersionOf<T>;

Remarks

Only generics signatures on function that returning an Promise will be preserved due to the limitation of TypeScript.

Method called then are intentionally removed because it is very likely to be a foot gun in promise auto-unwrap.