Skip to content

Commit 8c8953c

Browse files
committed
lib: add Math.sumPrecise type definition (ES2026 / esnext)
Math.sumPrecise is part of the TC39 proposal-math-sum which reached Stage 4 on 2025-07-28, making it part of ES2026. Already implemented in Firefox 137+, Safari 18.4, and Bun, but not yet in V8/Node.js. Adds src/lib/esnext.math.d.ts with the Math interface extension, and wires it into esnext.d.ts and libs.json. Fixes #63427
1 parent 55423ab commit 8c8953c

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/lib/es2025.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
/// <reference lib="es2025.collection" />
33
/// <reference lib="es2025.float16" />
44
/// <reference lib="es2025.intl" />
5-
/// <reference lib="es2025.iterator" />
5+
/// <reference lib="es2025.iterator" />
66
/// <reference lib="es2025.promise" />
77
/// <reference lib="es2025.regexp" />

src/lib/esnext.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/// <reference lib="esnext.typedarrays" />
1010
/// <reference lib="esnext.temporal" />
1111
/// <reference lib="esnext.date" />
12+
/// <reference lib="esnext.math" />

src/lib/esnext.math.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference lib="es2015.iterable" />
2+
3+
interface Math {
4+
/**
5+
* Returns the sum of the values in the iterable using a more precise
6+
* summation algorithm than naive floating-point addition.
7+
* Returns `-0` if the iterable is empty.
8+
* @param numbers An iterable (such as an Array) of numbers.
9+
* @throws {TypeError} If `numbers` is not iterable, or if any value in the iterable is not of type `number`.
10+
* @throws {RangeError} If the iterable yields 2^53 or more values.
11+
* @see https://tc39.es/proposal-math-sum/
12+
*/
13+
sumPrecise(numbers: Iterable<number>): number;
14+
}

src/lib/libs.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@
8383
"es2025.collection",
8484
"es2025.float16",
8585
"es2025.intl",
86-
"es2025.iterator",
86+
"es2025.iterator",
8787
"es2025.promise",
8888
"es2025.regexp",
89-
"esnext.array",
89+
"esnext.array",
90+
"esnext.math",
9091
"esnext.collection",
9192
"esnext.date",
9293
"esnext.decorators",

0 commit comments

Comments
 (0)