callback-through-param.ts 595 B

123456789101112
  1. // Callback invocation family: a callback handed to a helper and invoked through the helper's
  2. // PARAMETER. The checker cannot resolve `job()` to a declaration, but the call oracle knows
  3. // the parameter holds the arrow, so the body inlines inside `withRetry`'s call region — in
  4. // phase#1, before the checker's ask in phase#2.
  5. phase("work");
  6. async function withRetry(job: () => Node<string>): Promise<string> {
  7. return await job();
  8. }
  9. const a = await withRetry(() => agent("worker").ask<string>("do it"));
  10. phase("check");
  11. const b = await agent("checker").ask<string>(`check ${a}`);
  12. return b;