es-lib-globals.ts 816 B

123456789101112131415161718192021222324
  1. // Exercises the embedded ES2022 stdlib closure end to end: if the compiler host
  2. // is missing any lib file, these globals fail to resolve and the fixture (which
  3. // carries no `// error` markers) fails the strict clean-compile check.
  4. interface Item {
  5. id: number;
  6. label: string;
  7. }
  8. const collect = async (id: number): Promise<Item> => {
  9. const label = await agent("worker").ask(`describe ${id}`);
  10. return { id, label };
  11. };
  12. const ids = Array.from({ length: 3 }, (_unused, index) => index);
  13. const items: Item[] = await Promise.all(ids.map((id) => collect(id)));
  14. const seen = new Set<number>();
  15. const byId = new Map<number, string>();
  16. for (const item of items) {
  17. seen.add(item.id);
  18. byId.set(item.id, `${item.label} (#${item.id})`);
  19. }
  20. return JSON.stringify({ count: seen.size, labels: [...byId.values()] });