async-call-rpc

A lightweight JSON RPC client & server

Home > async-call-rpc > AsyncGeneratorVersionOf

AsyncGeneratorVersionOf type

Make all generator in the type T becomes AsyncGenerator

Signature:

export type AsyncGeneratorVersionOf<T> = T extends Record<keyof T, _IteratorOrIterableFunction> ? 'then' extends keyof T ? Omit<Readonly<T>, 'then'> : T : _AsyncGeneratorVersionOf<T>;

Remarks

Only generics signatures on function that returning an AsyncGenerator 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.