diff --git a/mediapipe/web/graph_runner/graph_runner.ts b/mediapipe/web/graph_runner/graph_runner.ts index 795cd4061..4417f6a03 100644 --- a/mediapipe/web/graph_runner/graph_runner.ts +++ b/mediapipe/web/graph_runner/graph_runner.ts @@ -1123,6 +1123,18 @@ async function runScript(scriptUrl: string) { } } +/** + * Helper type macro for use with createMediaPipeLib. Allows us to easily infer + * the type of a mixin-extended GraphRunner. Example usage: + * const GraphRunnerConstructor = + * SupportImage(SupportSerialization(GraphRunner)); + * let mediaPipe: ReturnType; + * ... + * mediaPipe = await createMediaPipeLib(GraphRunnerConstructor, ...); + */ +// tslint:disable-next-line:no-any +export type ReturnType = T extends (...args: unknown[]) => infer R ? R : any; + /** * Global function to initialize Wasm blob and load runtime assets for a * specialized MediaPipe library. This allows us to create a requested