# hasKeys

`function` in `utils` · v0.7.0

<https://docs.seedcord.org/packages/utils/0.7.0/functions/has-keys>

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.

```ts
hasKeys<Obj, Keys>(
    obj: Obj,
    keys: Keys[]
): obj is Obj &
    UnionToIntersection<
        Keys extends unknown
            ? PathToObj<
                  Keys,
                  UnionToIntersection<
                      NonNullable<DeepGet<Obj, Keys>>
                  >
              >
            : never
    >
```

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.

Parameters.

- `obj` `Obj` — The object to check.
- `keys` `Keys[]` — An array of dot-notation paths to check.

Returns `obj is Obj & UnionToIntersection<Keys extends unknown ? PathToObj<Keys, UnionToIntersection<NonNullable<DeepGet<Obj, Keys>>>> : never>`.
