Skip to content

Commit

Permalink
fix: define input as string types when verifying possible key values
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusBaldi committed Jan 14, 2025
1 parent 754599c commit 536535c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ function isKey(value: unknown, object: unknown): boolean {
return true;
}

return IS_PLAIN_PROP_REGEX.test(value) || !IS_DEEP_PROP_REGEX.test(value) ||
(object !== null && object !== undefined && value in Object(object));
return IS_PLAIN_PROP_REGEX.test(value as string)
|| !IS_DEEP_PROP_REGEX.test(value as string)
|| (object !== null && object !== undefined && value as string in Object(object));
}

const DOT_CHAR_CODE = '.'.charCodeAt(0),
Expand Down Expand Up @@ -98,7 +99,7 @@ function createPathArray(value: unknown, object: unknown): string[] {
return value;
}

return isKey(value, object) ? [ value ] : stringToPath(value);
return isKey(value, object) ? [ value as string ] : stringToPath(value as string);
}

interface StringRepresentable {
Expand Down

0 comments on commit 536535c

Please sign in to comment.