Skip to content

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

Comment on lines +1 to +2
// @target: es2022
// @lib: es2022.intl
Copy link
Contributor

Choose a reason for hiding this comment

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

es2022.intl doesn't reference lib.es5, so Collator isn't actually defined in your test script (check the baselines).

Either change this to

Suggested change
// @target: es2022
// @lib: es2022.intl
// @target: es5
// @lib: es5

or just get rid of the lib option entirely, and use the default.

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