Branded numeric type for safe integers. Represents integers that can be exactly represented in JavaScript (±2^53 - 1).
const isSafeInt = (x: number): x is SafeInt => Number.isSafeInteger(x);const safeMath = { add: (a: SafeInt, b: SafeInt): SafeInt | undefined => { const result = a + b; return isSafeInt(result) ? result : undefined; }}; Copy
const isSafeInt = (x: number): x is SafeInt => Number.isSafeInteger(x);const safeMath = { add: (a: SafeInt, b: SafeInt): SafeInt | undefined => { const result = a + b; return isSafeInt(result) ? result : undefined; }};
Branded numeric type for safe integers. Represents integers that can be exactly represented in JavaScript (±2^53 - 1).