Skip to content

Commit 690af4e

Browse files
committed
lib: add Math.sumPrecise type definition (ES2025)
Math.sumPrecise is part of the TC39 proposal-math-sum that shipped in ES2025. Firefox 137+ and Bun have already implemented it, but TypeScript lacks the corresponding type definition in lib.d.ts. Adds src/lib/es2025.math.d.ts with the Math interface extension, and wires it into es2025.d.ts and libs.json. Fixes #63427
1 parent 55423ab commit 690af4e

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/lib/es2025.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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" />
6+
/// <reference lib="es2025.math" />
67
/// <reference lib="es2025.promise" />
78
/// <reference lib="es2025.regexp" />

src/lib/es2025.math.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
* @param values An iterable of numbers to sum.
8+
* @throws {TypeError} If any value in the iterable is not of type Number (e.g. BigInt).
9+
* @see https://tc39.es/proposal-math-sum/
10+
*/
11+
sumPrecise(values: Iterable<number>): number;
12+
}

src/lib/libs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
"es2025.collection",
8484
"es2025.float16",
8585
"es2025.intl",
86-
"es2025.iterator",
86+
"es2025.iterator",
87+
"es2025.math",
8788
"es2025.promise",
8889
"es2025.regexp",
8990
"esnext.array",

0 commit comments

Comments
 (0)