Skip to content

fix(Intl): make Intl.Collator.compare a getter that returns a bound function (#62048) #62052

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahsansheikh94
Copy link

@ahsansheikh94 ahsansheikh94 commented Jul 12, 2025

What this PR does

This PR updates the type definition for Intl.Collator.prototype.compare to align with the ECMAScript specification.

Previously, compare was declared as a method:
compare(x: string, y: string): number;

According to the spec, it is a getter that returns a bound function:
get compare(): (this: void, x: string, y: string) => number;

Changing this to a getter would cause conflicts with the existing implementations as pointed out by @Renegade334.
Instead adding a this: void gets the job done.

Changes made

  • Updated the Intl.Collator interface in src/lib/es5.d.ts:
  • Added a new conformance test in tests/cases/conformance/intl/collatorCompareBoundFunction.ts

Related Issue

Fixes #62048

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 12, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jul 12, 2025
@ahsansheikh94
Copy link
Author

@microsoft-github-policy-service agree

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.

Intl.Collator#compare method type does not match spec
3 participants