Skip to content

Commit

Permalink
fix: add arrays to valid parameter types
Browse files Browse the repository at this point in the history
  • Loading branch information
PopGoesTheWza committed Dec 27, 2023
1 parent 99583c6 commit 40bb3d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ getProperty({foo: [{bar: 'unicorn'}]}, 'foo[0].bar');
//=> 'unicorn'
```
*/
export function getProperty<ObjectType, PathType extends string, DefaultValue = undefined, ReturnType = ObjectType extends AnObject | AFunction ? (unknown extends Get<ObjectType, PathType> ? DefaultValue : Get<ObjectType, PathType>) : undefined>(
export function getProperty<ObjectType, PathType extends string, DefaultValue = undefined, ReturnType = ObjectType extends AFunction | AnArray | AnObject ? (unknown extends Get<ObjectType, PathType> ? DefaultValue : Get<ObjectType, PathType>) : undefined>(
object: ObjectType,
path?: PathType,
defaultValue?: DefaultValue,
Expand Down Expand Up @@ -371,7 +371,7 @@ hasProperty({foo: {bar: 'unicorn'}}, 'foo.bar');
//=> true
```
*/
export function hasProperty(object: AnObject | AFunction | undefined, path?: string): boolean {
export function hasProperty(object: AFunction | AnArray | AnObject | undefined, path?: string): boolean {
if (!isObject(object) || typeof path !== 'string') {
return false;
}
Expand Down

0 comments on commit 40bb3d6

Please sign in to comment.