Skip to content

validator function crashes if it encounters BigInt #67

Closed
@t-winter

Description

@t-winter

The validation function throws a TypeError if it encounters a BigInt where it expected something else.

Example: assertEquals<string>(BigInt(1))

This occurs since 0.16.1 and appears to be caused by the incompatibility of JSON.stringify() with the BigInt data type when returning the value that was found where another type was expected.
I'd like to add that JSON.stringify() has other issues (most notably incompatibility with circular references).

I suggest using util.inspect() if available (i.e. when used in a node environment) and JSON.stringify() in a try/catch block if not (and either omit the encountered object or print it directly to the console with console.dir() on errors).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions