```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 (!defs[unit]) {
        throw new Error(`Unit '${unit}' is not defined.`);
    }

    const [factor, finer] = defs[unit];
    if (finer === base) {
        return amount;
    } else if (defs[finer]) {
        return baseAmount(amount * factor, finer, defs, base);
    } else {
        throw new Error("Chain loops so it can never reach the base.");
    }
}
```