Functionutilsv0.6.1
hasKeys
Checks for the presence of nested keys in an object that's possibly a distributed union, narrowing the object type accordingly.
Checks if an object has the specified nested keys and that their values are not null or undefined. If they are not, the object type is narrowed to reflect the presence of these keys with their respective types from the original distributed union object.
hasKeys<Obj, Keys>(
obj: Obj,
keys: Keys[]
): obj is Obj &
UnionToIntersection<
Keys extends unknown
? PathToObj<
Keys,
UnionToIntersection<
NonNullable<DeepGet<Obj, Keys>>
>
>
: never
>hasKeys<Obj, Keys>(
obj: Obj,
keys: Keys[]
): obj is Obj &
UnionToIntersection<
Keys extends unknown
? PathToObj<
Keys,
UnionToIntersection<
NonNullable<DeepGet<Obj, Keys>>
>
>
: never
>Obj
ObjObjKeys
KeysKeysobj
obj: Objobj: ObjThe object to check.
keys
keys: Keys[]keys: Keys[]An array of dot-notation paths to check.