lib: add Math.sumPrecise type definition (ES2025)#63589
Conversation
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 microsoft#63427
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
1 similar comment
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
|
@kamalkarki111 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
@kamalkarki111 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Adds a new esnext lib slice for the Stage 4 Math.sumPrecise proposal and wires it into lib selection, diagnostics, and conformance coverage.
Changes:
- Introduces
src/lib/esnext.math.d.tsto declareMath.sumPrecise(numbers: Iterable<number>): number. - Registers the new lib name (
esnext.math) and ensures it is reachable via/// <reference lib="...">and--lib. - Adds a conformance test plus updated baselines reflecting the new
--liboption value.
Reviewed changes
Copilot reviewed 14 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/cases/conformance/esnext/mathSumPrecise.ts | New conformance test exercising Math.sumPrecise typing under @lib: esnext. |
| tests/baselines/reference/mathSumPrecise.types | New baseline validating inferred types for the conformance test. |
| tests/baselines/reference/mathSumPrecise.symbols | New baseline validating symbol resolution for Math.sumPrecise. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js | Baseline update to include esnext.math in TS6046 allowed --lib values. |
| src/lib/libs.json | Registers esnext.math in the known lib-name list. |
| src/lib/esnext.math.d.ts | New lib slice adding the Math.sumPrecise declaration. |
| src/lib/esnext.d.ts | Ensures esnext includes esnext.math via a lib reference. |
| src/compiler/utilities.ts | Adds sumPrecise to ScriptTargetFeatures for Math under esnext (used for lib/target suggestion diagnostics). |
| src/compiler/commandLineParser.ts | Maps --lib esnext.math to lib.esnext.math.d.ts. |
Files not reviewed (3)
- tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js: Generated file
- tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js: Generated file
- tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js: Generated file
| // ESNext By-feature options | ||
| ["esnext.array", "lib.esnext.array.d.ts"], | ||
| ["esnext.array", "lib.esnext.array.d.ts"], | ||
| ["esnext.math", "lib.esnext.math.d.ts"], | ||
| ["esnext.collection", "lib.esnext.collection.d.ts"], |
| "esnext.array", | ||
| "esnext.math", | ||
| "esnext.collection", | ||
| "esnext.date", |
| function* gen(): Iterable<number> { | ||
| yield 0.1; | ||
| yield 0.2; | ||
| } | ||
| const sum5 = Math.sumPrecise(gen()); |
Summary
Adds type definition for
Math.sumPrecisewhich is part of the TC39proposal-math-sumthat reached Stage 4 on 2025-07-28, making it part of ES2026.Changes
src/lib/esnext.math.d.ts— extendsinterface MathwithsumPrecisesrc/lib/esnext.d.ts— added/// <reference lib="esnext.math" />src/lib/libs.json— registeredesnext.mathin the libs arraysrc/compiler/commandLineParser.ts— mappedesnext.mathlib name to filesrc/compiler/utilities.ts— addedsumPrecisetoScriptTargetFeaturesfor helpful diagnosticsWhy esnext, not es2025?
The proposal reached Stage 4 on 2025-07-28, one month after ES2025 was finalized (June 2025), so it will be included in ES2026. TypeScript does not have
es2026lib files yet, soesnextis the correct placement for now.Runtime support
References
Based on the same changes as #63429