devtypes - v2.1.0
    Preparing search index...

    Type Alias JSONBadValueTypes

    JSONBadValueTypes: bigint | undefined | Function | Symbol

    All JSON bad values types.

    Includes the types that are not valid JSON values and will be:

    • Omitted when found in an object.
    • Changed to [null] if found in an array.
    • Will cause the stringification process to return undefined.

    bigint will throw an error. In theory bigint can be handled by monkey patching BigInt.prototype.toJSON = ..., then converted to an object and parsed with a custom JSON parser. Which is out of scope in this context.

    Warnings, things TS cannot protect you against:

    JSON.stringify( { a: undefined, b: () => {}, c: Symbol( '' ) } )  // '{}'
    JSON.stringify( undefined ) // undefined
    JSON.stringify( () => {} ) // undefined
    JSON.stringify( Symbol( 's' ) ) // undefined
    JSON.stringify( [ undefined, () => {}, Symbol( 's' ) ] ) // '[ null, null, null ]'
    JSON.stringify( BigInt( 1 ) ) // Type Error