Skip to content

lib: add Math.sumPrecise type definition (ES2025) - #63429

Open
827652549 wants to merge 2 commits into
microsoft:mainfrom
827652549:fix/add-math-sumPrecise-lib-type
Open

lib: add Math.sumPrecise type definition (ES2025)#63429
827652549 wants to merge 2 commits into
microsoft:mainfrom
827652549:fix/add-math-sumPrecise-lib-type

Conversation

@827652549

@827652549 827652549 commented Apr 24, 2026

Copy link
Copy Markdown

Summary

Adds type definition for Math.sumPrecise which is part of the TC39 proposal-math-sum that reached Stage 4 on 2025-07-28, making it part of ES2026.

Changes

  • New file: src/lib/esnext.math.d.ts — extends interface Math with sumPrecise
  • Updated src/lib/esnext.d.ts — added /// <reference lib="esnext.math" />
  • Updated src/lib/libs.json — registered esnext.math in the libs array
  • Updated src/compiler/commandLineParser.ts — mapped esnext.math lib name to file
  • Updated src/compiler/utilities.ts — added sumPrecise to ScriptTargetFeatures for helpful diagnostics

Why 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 es2026 lib files yet, so esnext is the correct placement for now.

Runtime support

Runtime Supported
Firefox 137+
Safari 18.4 (JavaScriptCore)
Bun
V8 / Node.js / Chrome ❌ not yet

References

AI Disclosure

This PR was developed with AI assistance (Claude by Anthropic) for research, code generation, and verification against the TC39 spec, MDN, and runtime implementations.

Fixes #63427

@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Apr 24, 2026
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 24, 2026
@827652549
827652549 force-pushed the fix/add-math-sumPrecise-lib-type branch from 690af4e to 8c8953c Compare April 24, 2026 04:41
@827652549

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@827652549
827652549 force-pushed the fix/add-math-sumPrecise-lib-type branch 4 times, most recently from da8c0cf to 769ae58 Compare April 24, 2026 05:10
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
Copilot AI lite review requested due to automatic review settings August 4, 2026 04:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new ESNext-by-feature library (esnext.math) to provide type definitions for Math.sumPrecise, and wires it through the lib registry / CLI parsing so it can be selected via --lib, with conformance + baseline coverage.

Changes:

  • Added src/lib/esnext.math.d.ts to extend interface Math with sumPrecise(numbers: Iterable<number>): number.
  • Registered esnext.math in the lib ecosystem (src/lib/libs.json, src/lib/esnext.d.ts, and src/compiler/commandLineParser.ts).
  • Added diagnostics support and test coverage (new conformance test + updated baselines).

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
tests/cases/conformance/esnext/mathSumPrecise.ts New conformance test exercising Math.sumPrecise typing (positive + negative cases).
tests/baselines/reference/mathSumPrecise.types New types baseline validating the inferred types for the conformance test.
tests/baselines/reference/mathSumPrecise.symbols New symbols baseline validating symbol binding to lib.esnext.math.d.ts.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js Baseline update reflecting esnext.math in valid --lib values list.
tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js Baseline update reflecting esnext.math in valid --lib values list.
src/lib/libs.json Registers esnext.math as a known lib for --lib parsing and ordering.
src/lib/esnext.math.d.ts New lib fragment defining Math.sumPrecise.
src/lib/esnext.d.ts Includes esnext.math in the aggregate esnext lib.
src/compiler/utilities.ts Adds sumPrecise to ScriptTargetFeatures (used for “Try changing the 'lib' option to … or later” suggestions).
src/compiler/commandLineParser.ts Maps esnext.math to lib.esnext.math.d.ts and adds it to the recognized --lib values list.
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

Comment on lines +18 to +21
function* gen(): Iterable<number> {
yield 0.1;
yield 0.2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Add type definition for Math.sumPrecise (ES2025 / TC39 proposal)

3 participants