Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
bigint is a primitive data type in TypeScript used to represent arbitrarily large integers beyond the safe integer limit of the standard number type (Number.MAX_SAFE_INTEGER, or ).
You can initialize a bigint by appending an n suffix to an integer literal or by calling the global BigInt() function.
Type Interoperability and Strictness
TypeScript enforces strict separation betweenbigint and number. There is no implicit type coercion between the two primitives. Attempting to mix them in arithmetic operations will result in a compile-time type error, requiring explicit casting to perform operations across the two types.
While bigint and number can be safely mixed in relational comparisons (<, >, <=, >=) and loose equality comparisons (==, !=), strict equality comparisons (===, !==) are forbidden. Because bigint and number are disjoint types with no overlap, TypeScript explicitly rejects strict equality checks between them and will throw a compile-time error (TS2367).
Mathematical and Bitwise Operations
bigint supports standard arithmetic operators (+, -, *, /, %, **) and bitwise operators (&, |, ^, ~, <<, >>). Notably, the unsigned right shift operator (>>>) is explicitly unsupported for bigint types, as bigint does not have a fixed bit-width to shift into.
Because bigint strictly represents whole numbers, division operations inherently truncate fractional components towards zero. Furthermore, bigint primitives are incompatible with the built-in Math object methods, which strictly expect number arguments.
Compiler Configuration
Becausebigint is a relatively recent ECMAScript feature, the TypeScript compiler requires a specific target to emit valid code. Your tsconfig.json must have the target set to ES2020 or later. If targeting an older ECMAScript version, TypeScript will throw a compilation error, as bigint cannot be polyfilled or down-compiled to standard JavaScript numbers without losing precision.
Master TypeScript with Deep Grasping Methodology!Learn More





