File tree 2 files changed +10
-2
lines changed 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -421,7 +421,11 @@ function buildTree(
421
421
// `Date`, `RegExp` and `Error`
422
422
if ( value instanceof Date || value instanceof RegExp ) {
423
423
const type = value instanceof Date ? "Date" : "RegExp" ;
424
- let str = type === "Date" ? ( value as Date ) . toISOString ( ) : value . toString ( ) ;
424
+ let str =
425
+ type === "Date" ?
426
+ isNaN ( value as any ) ? "Invalid Date"
427
+ : ( value as Date ) . toISOString ( )
428
+ : value . toString ( ) ;
425
429
// The rule of `Symbol.toStringTag` for `Date`s and `RegExp`s is different from other
426
430
// objects, so we should handle it here.
427
431
const toStringTag = getToStringTag ( value , showHidden ) ;
Original file line number Diff line number Diff line change @@ -523,7 +523,11 @@ function buildTree(
523
523
// `Date`, `RegExp` and `Error`
524
524
if ( value instanceof Date || value instanceof RegExp ) {
525
525
const type = value instanceof Date ? "Date" : "RegExp" ;
526
- let str = type === "Date" ? ( value as Date ) . toISOString ( ) : value . toString ( ) ;
526
+ let str =
527
+ type === "Date" ?
528
+ isNaN ( value as any ) ? "Invalid Date"
529
+ : ( value as Date ) . toISOString ( )
530
+ : value . toString ( ) ;
527
531
// The rule of `Symbol.toStringTag` for `Date`s and `RegExp`s is different from other
528
532
// objects, so we should handle it here.
529
533
const toStringTag = getToStringTag ( value , showHidden ) ;
You can’t perform that action at this time.
0 commit comments