Files
scriptc/tests/diagnostics/maps-surface.ts
Chris Tate e2d58f60d2 Expand static support for common Effect 4 patterns (#600)
* Expand static compilation for common Effect 4 patterns

* Run every Effect 4 fixture slice in CI

* Preserve existing corpus behavior across Effect 4 lowering

* Preserve Effect platform callbacks and native stream state

* Record new corpus baselines and retain child stdin refusals

* Retire the obsolete stateful regex diagnostic

* Preserve promise reference count layout for cycle collection
2026-10-01 17:36:29 -05:00

27 lines
1.1 KiB
TypeScript

// The Map surface beyond the lowering: the lib declares all of this, so
// it TYPECHECKS (seeded constructors, iterators, chaining, 3-param forEach
// callbacks) — each use is fenced per site by the lowerer, never truncated.
const m = new Map<string, number>();
// Entry-seeded construction lowers for an array literal of pair literals
// at the construction site and for [K, V][]-typed tuple-array values;
// other seeds (another Map, general iterables) stay fenced.
const seeded = new Map(m);
// keys()/values()/entries() lower ONLY where an array spread drains them
// on the spot ([...m.keys()]); a stored iterator would need the protocol.
const ks = m.keys();
const vs = m.values();
const es = m.entries();
// Spreading the MAP itself (no [Symbol.iterator] lowering) stays fenced —
// for-of over the map and spreads of its keys()/values()/entries() are the
// lowered iteration forms.
const spread = [...m];
// set() returns the same Map, so chained mutations compile.
m.set("a", 1).set("b", 2);
// The forEach callback receives (value, key) — no third map parameter.
m.forEach((v, k, theMap) => console.log(k, v));