Skip to content

Commit

Permalink
fix looseEq if one value is an object
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Nov 11, 2024
1 parent 0df61e4 commit 004c6b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/tsconfig/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ function wrapMatcher(matcher: Matcher, message: (actual: any) => string, allowed
*/
function looseEqual(a: any, b: any): boolean {
try {
// if one of the values is an object (or array), but the other isn't - never consider them the same
if ([typeof a, typeof b].filter((t) => t === 'object').length === 1) {
return false;
}
// if both values are the same object
// or if both values are loose equal
return Object.is(a, b) || a == b;
} catch {
return false;
Expand Down
1 change: 0 additions & 1 deletion test/tsconfig/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ describe('Built-in matchers', () => {
});
},
),
{ seed: 1484060133, path: "26", endOnFailure: true }
);
});
});
Expand Down

0 comments on commit 004c6b7

Please sign in to comment.