control-flow-comma-alias-write.ts 349 B

12345678
  1. // The comma (sequence) operator yields its RIGHT operand at runtime, so
  2. // `alias` and `box` are ONE object; a write through alias is visible via box.
  3. const box = { note: "" };
  4. let picks = 0;
  5. const alias = (picks++, box);
  6. alias.note = await agent("a").ask<string>("secret");
  7. log(`picks ${picks}`);
  8. return agent("b").ask<string>(`use ${box.note}`);