Skip to content

Commit

Permalink
fix(isEqual): types
Browse files Browse the repository at this point in the history
  • Loading branch information
djalmajr committed May 16, 2022
1 parent 4ee78d3 commit dfa8691
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/isEqual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { size } from './size';

const { keys } = Object;

export const isEqual = curry((source: never, target: never): boolean => {
export const isEqual = curry((source: unknown, target: unknown): boolean => {
if (!isObject(source) || !isObject(target)) {
return source === target;
}
Expand All @@ -14,10 +14,13 @@ export const isEqual = curry((source: never, target: never): boolean => {
}

return keys(source).every((key: string): boolean => {
if (isObject(source[key]) && isObject(target[key])) {
return isEqual(source[key], target[key]);
if (
isObject(source[key as keyof typeof source]) &&
isObject(target[key as keyof typeof target])
) {
return isEqual(source[key as keyof typeof source], target[key as keyof typeof target]);
}

return source[key] === target[key];
return source[key as keyof typeof source] === target[key as keyof typeof target];
});
});

0 comments on commit dfa8691

Please sign in to comment.