Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

TypeError: Cannot mix BigInt and other types

Illustration without a description Illustration without a description

This exception often comes from combining a BigInt counter or timestamp with a Number literal. The values can look alike in the surrounding code, so inspect both operands with typeof. A literal such as 1n makes the type explicit when an increment belongs in BigInt arithmetic.

 

Choose the numeric type that fits the data before converting anything. For integer work that needs to preserve large values, keep the operation in BigInt. Convert to Number only after confirming the value is within the safe integer range if exactness matters.

 

Writing 1n keeps the increment in the same numeric type as the counter. When one operand comes from an API and the other is written in code, trace the API value to the point where it was parsed. Normalizing it there can keep several later calculations from making different assumptions about the same field.

 

const count = 10n; const next = count + 1n; // BigInt + BigInt const asNumber = Number(next); // Only after a safe-range check if needed

 

Inspect typeof on both sides of the failing operator and repeat the operation with operands of the same numeric type.