control-flow-if-no-else-skip.ts 596 B

1234567891011121314
  1. // A skippable choice vs an exhaustive one. The first `if` has no else, so its head has a
  2. // `branch` edge straight to the step after it; the second has an else, so control must pass
  3. // through one of its arms and there is no skip edge.
  4. const scan = await agent("scanner").ask<string>("scan");
  5. if (scan.includes("todo")) {
  6. await agent("fixer").ask<string>(`fix todos in ${scan}`);
  7. }
  8. let verdict: string;
  9. if (scan.includes("risky")) {
  10. verdict = await agent("auditor").ask<string>(`audit ${scan}`);
  11. } else {
  12. verdict = await agent("approver").ask<string>(`approve ${scan}`);
  13. }
  14. return verdict;