```typescript
export function slotHits(keys: number[], slots: number): number {
  if (!Array.isArray(keys) || keys.some(key => typeof key !== 'number')) {
    throw new Error('keys must be an array of integers');
  }
  if (typeof slots !== 'number' || slots <= 0 || !Number.isInteger(slots)) {
    throw new Error('slots must be a positive integer');
  }

  const cache: { [key: number]: number | null } = {};

  let hits = 0;

  for (const key of keys) {
    const slot = Math.abs(key) % slots;
    if (cache[slot] === key) {
      hits++;
    } else if (cache[slot]) {
      // Replace the existing value with null to indicate it's been evicted
      cache[slot] = null;
    }
    cache[slot] = key;
  }

  return hits;
}
```