TypeError: Cannot mix BigInt and other types
Quick summary
You added or compared a BigInt with a Number — JavaScript does not implicitly convert, so the operation fails.
Why this happens
Adding a BigInt and a Number with +, -, *, or /
Reading a BigInt from one source and a Number from another without converting
Using Math methods (which only accept Number) on a BigInt
Minimal example
const big = 10n;
const sum = big + 5; // TypeError: Cannot mix BigInt and other types
console.log(sum);const big = 10n;
const sum = big + BigInt(5); // 15n
console.log(sum);You cannot add a BigInt and a Number directly. Converting 5 to BigInt with BigInt(5) makes both operands the same type.
How to diagnose
Read the TypeError: 'Cannot mix BigInt and other types'
Check typeof on both operands to identify the BigInt
Look for Math.* calls that receive a BigInt argument
How to fix
Convert both operands to the same type before arithmetic
Use BigInt(n) to convert a Number to BigInt, or Number(b) for the reverse
Avoid Math methods with BigInt — use BigInt-native operations
How to prevent
Decide on one numeric type per calculation and convert at the boundaries
Use TypeScript bigint vs number types to keep them separate