```ts
export function baseAmount(amount: number, unit: string, defs: Record<string, [number, string]>, base: string): number {
  if (amount < 0 || !Number.isInteger(amount)) throw new Error("Amount must be a non-negative whole number");
  if (!(unit in defs) && unit !== base) throw new Error("Unknown unit");
  
  const seen = new Set<string>();
  
  while (unit !== base) {
    if (seen.has(unit)) throw new Error("Loop detected in definition chain");
    seen.add(unit);
    
    const [factor, finer] = defs[unit];
    if (factor <= 0 || !Number.isInteger(factor)) throw new Error("Bad factor");
    amount *= factor;
    unit = finer;
  }
  
  return amount;
}
```