lib: add Math.sumPrecise type definition (ES2025)#63590
Conversation
|
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”),
|
There was a problem hiding this comment.
Pull request overview
Adds an esnext lib definition for the Stage 4 Math.sumPrecise API and wires it into TypeScript’s lib selection pipeline (--lib//// <reference lib=... />), along with conformance coverage and updated baselines.
Changes:
- Added new lib file
esnext.mathdefiningMath.sumPrecise(numbers: Iterable<number>): number. - Registered
esnext.mathas a selectable lib and included it fromesnext. - Added a conformance test plus updated reference/config baselines (notably TS6046’s allowed
--liblist).
Reviewed changes
Copilot reviewed 14 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/lib/esnext.math.d.ts |
Introduces the Math.sumPrecise type definition under an esnext by-feature lib. |
src/lib/esnext.d.ts |
Ensures --lib esnext also brings in esnext.math. |
src/lib/libs.json |
Registers esnext.math in the library registry used by the build/tooling. |
src/compiler/commandLineParser.ts |
Maps esnext.math to lib.esnext.math.d.ts for --lib parsing/resolution. |
src/compiler/utilities.ts |
Adds sumPrecise to ScriptTargetFeatures for improved “missing lib” diagnostics. |
tests/cases/conformance/esnext/mathSumPrecise.ts |
Adds a conformance test validating the new lib surface area and type errors. |
tests/baselines/reference/mathSumPrecise.types |
New types baseline for the conformance test. |
tests/baselines/reference/mathSumPrecise.symbols |
New symbols baseline for the conformance test. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js |
Updates TS6046 allowed-lib list to include esnext.math. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js |
Updates TS6046 allowed-lib list to include esnext.math. |
tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js |
Same TS6046 allowed-lib list update. |
tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js |
Same TS6046 allowed-lib list update. |
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
| // Works with any Iterable<number> | ||
| const sum4 = Math.sumPrecise(new Set([1, 2, 3])); | ||
|
|
||
| function* gen(): Iterable<number> { |
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.References
Same changes as #63429 (recreated via GitHub MCP).