iterated-object-method-call.ts 625 B

123456789
  1. // A method stored on an object that is ITERATED by a fan-out callback stays reachable:
  2. // collapse carries the nested `run` function value through the element binding, so
  3. // `h.run(secret)` dispatches to run's summary instead of collapsing to an unknown call.
  4. // Expected: source -> ask#1, ask#1 -> ask#2 (secret into run's judge ask); fan-out#1 is
  5. // present (the forEach body reaches a facade sink); no sink edge (return literal).
  6. const secret = await agent("s").ask<string>("secret");
  7. const handlers = [{ run: (x: string) => agent("j").ask<string>(`judge ${x}`) }];
  8. handlers.forEach((h) => h.run(secret));
  9. return "done";