microsoft / microsoft/TypeScript

Intl.Collator#compare method type does not match spec

Open
#62,048 5 comments 1 reaction 2 assignees View on GitHub

@RyanCavanaugh is already working on this.

Since Sep 19, 2026.

  • #64344 by @copilot-swe-agent — open
Bug Domain: lib.d.ts Help Wanted Needs Human Review
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

⚙ Compilation target

ES2022

⚙ Library

N/A

Missing / Incorrect Definition

The Intl.Collator object has a compare method which is declared as compare(x: string, y: string): number; but according to the relevant spec is actually get compare(): (this: void, x: string, y: string) => number. Importantly, the spec states that

The returned function is bound to collator so that it can be passed directly to Array.prototype.sort or other functions

Sample Code

I'm having trouble putting together a Playground example that cares about the difference (which is admittedly subtle!) but it's the cause of https://github.com/typescript-eslint/typescript-eslint/issues/7098

Documentation Link

Collator#compare spec
MDN docs on compare method

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.