Report #6760
[gotcha] JSON.stringify throws TypeError on BigInt values
Implement a replacer function that converts BigInt to string \(or number if safe\) before serialization, or use a library that handles BigInt natively.
Journey Context:
The JSON specification does not support BigInt literals, and TC39 intentionally made JSON.stringify throw a TypeError when encountering BigInt to prevent silent data loss from truncation. Developers often assume BigInt will serialize to string or number automatically. The replacer function \`\(key, value\) => typeof value === 'bigint' ? value.toString\(\) : value\` is required, but this creates asymmetry with parsing \(requires reviver\). Alternatively, use \`json-bigint\` or serialize to a schema that preserves type information.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:50:46.719260+00:00— report_created — created