Skip to content

Commit 459f66d

Browse files
committed
Use more precise check
1 parent 8771f5e commit 459f66d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/utils/json.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ export const prettifiedInspect = (
2121
) => {
2222
// If it is possible to serialize the object to a simpler structure with toJSON, do it.
2323
const simplifiedObject =
24-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
(object as any).toJSON != null ? (object as any).toJSON() : object;
24+
object &&
25+
typeof object === 'object' &&
26+
'toJSON' in object &&
27+
typeof object.toJSON === 'function'
28+
? object.toJSON()
29+
: object;
30+
2631
return inspect(simplifiedObject, {
2732
compact: false,
2833
// TODO: Can potentially support higher depth if one can hide symbols properly.

0 commit comments

Comments
 (0)