```ts
export function baseAmount(amount: number, unit: string, defs: Record<string, [number, string]>, base: string): number {
    if (amount < 0 || !Number.isInteger(amount) || amount !== Math.abs(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;
    }

    return amount * factor + baseAmount(amount, finer, defs, base);
}
```