```ts
export function slotHits(keys: number[], slots: number): number {
  if (!Array.isArray(keys) || !keys.every(Number.isInteger)) {
    throw new Error("Invalid keys array");
  }
  if (typeof slots !== "number" || slots <= 0 || !Number.isInteger(slots)) {
    throw new Error("Invalid slot count");
  }

  const cache: number[] = Array.from({ length: slots }, () => -1);
  let hits = 0;

  for (const key of keys) {
    const index = key % slots;
    if (cache[index] === key) {
      hits++;
    } else {
      cache[index] = key;
    }
  }

  return hits;
}
```