Skip to content

Instantly share code, notes, and snippets.

@robertleeplummerjr
Created April 10, 2018 18:18
Show Gist options
  • Select an option

  • Save robertleeplummerjr/26e5066009b7573c38293feaaefa67de to your computer and use it in GitHub Desktop.

Select an option

Save robertleeplummerjr/26e5066009b7573c38293feaaefa67de to your computer and use it in GitHub Desktop.
class StaticBridge {
public static build<T>(Type: T, c: Api): any {
return Object.getOwnPropertyNames(Type)
.filter((prop) => typeof Type[prop] === "function")
.reduce((methods, method) => ({
// tslint:disable-next-line:no-any
...methods as any,
[method]: async (v: any): Promise<any> => {
return Type[method](v, c);
},
}), {});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment