type
int32
type int32 = number & { bun.int32: true }
A whole number from -2147483648 to 2147483647.
To TypeScript, and under bun run, this is a number. With --aot, a variable, field, parameter or return value of this type takes four bytes, and arithmetic on it skips the checks for fractions. The build must prove that every value stored in an int32 is one, and reports an error where it can't. | 0 turns any number into an int32.
import type { int32 } from "bun";
class Cursor { line: int32 = 0; column: int32 = 0; }
function advance(cursor: Cursor, by: int32) {
cursor.column = (cursor.column + by) | 0; // without `| 0` the sum could overflow: error TS100031
}