Skip to content

Add approximatelySign to NumberFormatPartTypeRegistry for ES2023 #62013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 7, 2025

The NumberFormatPartTypeRegistry interface was missing the approximatelySign part type, which is used by Intl.NumberFormat.formatRangeToParts() when ranges round to approximately the same value.

This caused TypeScript compilation errors when filtering format parts:

const nf = new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "EUR",
  maximumFractionDigits: 0,
});

// This would fail with TS error before the fix
nf
  .formatRangeToParts(value.from, value.to)
  .filter((part) => part.type !== "approximatelySign")
  .map((part) => part.value)
  .join("");

Changes:

  • Added approximatelySign: never; to NumberFormatPartTypeRegistry interface in src/lib/es2023.intl.d.ts
  • Updated ES2023 intl test to include validation of the new part type
  • Updated test baselines to reflect the change

The change follows the existing pattern used across ES versions for extending the NumberFormatPartTypeRegistry with new part types, ensuring TypeScript properly recognizes approximatelySign as a valid format part type.

Fixes #61960.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Jul 7, 2025
Copilot AI and others added 2 commits July 7, 2025 19:09
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] NumberFormatPartTypeRegistry doesn't have approximatelySign in it Add approximatelySign to NumberFormatPartTypeRegistry for ES2023 Jul 7, 2025
@Copilot Copilot AI requested a review from RyanCavanaugh July 7, 2025 19:27
Copilot finished work on behalf of RyanCavanaugh July 7, 2025 19:27
Copy link
Contributor

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

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

approximatelySign is a range-only type – in an ideal world, a separate NumberFormatRangePartTypeRegistry extends NumberFormatPartTypeRegistry interface would be the proper place for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NumberFormatPartTypeRegistry doesn't have approximatelySign in it
4 participants