Files
scriptc/tests/corpus/2111-json-stringify-unknown.ts
Chris Tate 6b6445ab90 Retire the "DOM" nickname in comments, internal docs, and message prose: the checked-dynamic tree / dyn values
- The ratified rename rider (world-unification §7 lane 5): "DOM" collided with the browser DOM and, post-lane-1, the structure is no longer a document tree. Comments and doc prose now say "the checked-dynamic tree" for the noun and "dyn" adjectivally; runtime symbol names (scr_dyn_*), the error.domClone libCall, and the real web DOMException family are unchanged.
- The few user-facing strings carrying the nickname move with it (the structuredClone cyclic message, the dc subscriber/publish fences, two emitter ICE texts); diagnostics snapshots regenerated (96 pass). One private compiler constant (DOM_PROTO_METHOD_NAMES -> DYN_PROTO_METHOD_NAMES) rides along.
- Mechanical sweep, 142 files, comments/prose only — no behavior change.
2026-07-24 11:14:58 -05:00

38 lines
1.7 KiB
TypeScript

// JSON.stringify over a dyn ROOT (unknown and the top object types): the
// runtime's dyn walker serializes what the type-directed serializers
// cannot see statically — the JSON.parse round-trip, unknown-typed locals,
// `{}`/`Object`/`object` slots. Number/string/bool/null/array/object are
// JS-exact; undefined MEMBERS drop like Node's; the pretty-print form
// re-indents the walker's compact text with the same gap algorithm.
// The round-trip: parse → unknown → stringify, with JS number spelling.
const parsed: unknown = JSON.parse('{"b":2,"a":[1,2.5,null],"s":"x"}');
console.log(JSON.stringify(parsed));
// Primitives and null through unknown roots.
const un: unknown = 42;
const us: unknown = "quote\"me";
const ub: unknown = false;
const unl: unknown = null;
console.log(JSON.stringify(un), JSON.stringify(us), JSON.stringify(ub), JSON.stringify(unl));
// A record built statically, stringified through an unknown slot: field
// order is insertion order, nested arrays/records walk recursively.
const u: unknown = { z: 1, a: { inner: [true, "t"] }, list: [3, 4] };
console.log(JSON.stringify(u));
// Top object types take the same walker.
const t1: {} = { k: "v" };
const t2: Object = [1, "two", null];
const t3: object = { nested: { n: 0.5 } };
console.log(JSON.stringify(t1), JSON.stringify(t2), JSON.stringify(t3));
// The pretty-print form over a dyn root: Node's space rules on the
// walker's compact output.
const pretty: unknown = JSON.parse('{"a":1,"b":[true,null]}');
console.log(JSON.stringify(pretty, null, 2));
// Non-finite numbers inside the checked-dynamic tree serialize as null, like Node.
const nf: unknown = { inf: Infinity, nan: 0 / 0, neg: -0 };
console.log(JSON.stringify(nf));