Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Type Alias

bigint

bigint is TypeScript’s primitive type for arbitrarily large integers. Values come from BigInt() or integer literals with an n suffix, and bigint arithmetic cannot mix with number operands.

Since
3.2

How it works

bigint is TypeScript’s primitive type for arbitrarily large integers. Create values with the BigInt() function or an integer literal ending in n; arithmetic requires bigint operands rather than mixing them with number values.

Syntax

let value: bigint = BigInt(100);
let literal: bigint = 100n;

Key points

  • bigint is a distinct primitive type, written in lowercase, rather than the BigInt constructor name.
  • Values can be created with BigInt() or with an integer literal using the n suffix.
  • The literal form appends n directly to an integer numeric literal, such as 100n.
  • A typeof value === "bigint" check can narrow a value to the bigint type.
  • Use bigint when integer values may exceed the safe precision range of ordinary JavaScript numbers.

Common mistakes

  • Do not mix number and bigint operands in arithmetic; convert explicitly first.
  • The documented release initially requires an esnext compilation target for BigInt support.
  • A compiler target or polyfill can provide a BigInt-like runtime object, but runtime support still matters.

Example: Using bigint values

const accountId: bigint = 9007199254740993n;
const fromText: bigint = BigInt("9007199254740993");

function add(a: bigint, b: bigint): bigint {
  return a + b;
}

console.log(add(accountId, fromText));

This runnable example declares bigint values using both supported creation forms and adds two bigint operands.

When to use it

Large integer values

Representing integer identifiers or counters that can exceed JavaScript number precision.

Precise arithmetic

Performing exact integer arithmetic without floating-point rounding at large magnitudes.

Type narrowing

Using runtime type guards for values whose type may be bigint.

  • BigInt()
  • number
  • typeof
  • esnext
  • esnext.bigint

Source: Documentation - TypeScript 3.2. Checked 2026-10-15.