# hasKeys

`function` in `utils` · v0.8.6-next.0

<https://docs.seedcord.org/packages/utils/0.8.6-next.0/functions/has-keys>

Checks that the specified nested keys exist on a possibly distributed union object and are not null or undefined, narrowing the object type to reflect those keys with their types from the original union.

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

Checks that the specified nested keys exist on a possibly distributed union object and are not null or undefined, narrowing the object type to reflect those keys with their types from the original union.

Parameters.

- `obj` `Obj`
- `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>`.
