Page Contents

Home > @loopback/context > AsyncProxy

AsyncProxy type

The proxy type for T. The return type for any method of T with original return type R becomes ValueOrPromise<R> if R does not extend Promise. Property types stay untouched.


export type AsyncProxy<T> = {
    [P in keyof T]: AsInterceptedFunction<T[P]>;

References: AsInterceptedFunction


class MyController {
  name: string;

  greet(name: string): string {
    return `Hello, ${name}`;

  async hello(name: string) {
    return `Hello, ${name}`;

AsyncProxy<MyController> will be:

  name: string; // the same as MyController
  greet(name: string): ValueOrPromise<string>; // the return type becomes `ValueOrPromise<string>`
  hello(name: string): Promise<string>; // the same as MyController