Skip to content

Commit

Permalink
fix(get): guard object access with optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
drizzer14 committed Dec 13, 2023
1 parent be0b883 commit 23d7a5e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function get(...args: [any, any?]): any {
let result = source as Get<Source, Path>

for (let index = 0; index < length; index += 1) {
result = result[keys[index] as keyof typeof result] as Get<Source, Path>
result = result?.[keys?.[index] as keyof typeof result] as Get<Source, Path>
}

return result
Expand Down

0 comments on commit 23d7a5e

Please sign in to comment.