You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSON.stringify of boxed primitive wrappers (new String/Number/Boolean) returns {} instead of the primitive #3857
JSON.stringify of a boxed primitive wrapper (new String(x) / new Number(x)
/ new Boolean(x)) returns {} instead of serializing via the wrapped primitive
value. Per spec, JSON.stringify calls the wrapper's internal [[StringData]] / [[NumberData]] / [[BooleanData]] (via toJSON/coercion), so a String wrapper
serializes as the JSON string, a Number wrapper as the number, etc.
Reproduction
console.log(JSON.stringify(newString("T")));// Perry: {} Node: "T"console.log(JSON.stringify(newNumber(42)));// Perry: {} Node: 42console.log(JSON.stringify(newBoolean(true)));// Perry: {} Node: true// Also surfaces via a primitive `this` (sloppy-mode boxing), e.g.functionf(this: any){returnthis;}console.log(JSON.stringify(f.apply("T",[])));// Perry: [... {} ...] Node: "T"
typeof already agrees ("object" for the wrapper in both), so the boxing itself
is correct — only the JSON.stringify serialization path doesn't unwrap.
A primitive this value passed to Function.prototype.apply/call is boxed to such
a wrapper (sloppy mode), so this is the residual difference in the #3828 minimal
repros that use a string thisArg (f.apply("T", [1,2])). It is independent of
call/apply/bind dispatch — it reproduces with new String("T") directly.
Notes
Found while fixing #3828 (PR #3856). The call/apply/bind dispatch itself is correct;
this is purely the JSON serializer not unwrapping boxed primitive wrapper objects.
Fixed in #3972 (merged to main as 4eede44, v0.5.1058). Verified byte-for-byte against node --experimental-strip-types with a node-suite regression fixture.
Activity
fix(node): API-surface hygiene batch (#3925, #3946, #3857, #3962, #3938…
proggeramlug commentedon Jun 1, 2026
Fixed in #3972 (merged to
mainas 4eede44, v0.5.1058). Verified byte-for-byte againstnode --experimental-strip-typeswith a node-suite regression fixture.