microsoft / microsoft/TypeScript

Intl.Collator#compare method type does not match spec

未关闭
#62,048 5 条评论 1 个 reaction 已指派 2 人 在 GitHub 查看

@RyanCavanaugh 已经在做这个了。

开始于 2026年9月19日。

  • #64344 来自 @copilot-swe-agent —— 未关闭
Bug Domain: lib.d.ts Help Wanted Needs Human Review
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

### ⚙ Compilation target

ES2022

### ⚙ Library

N/A

### Missing / Incorrect Definition

The [Intl.Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator) object has a `compare` method which is declared as `compare(x: string, y: string): number;` but according to [the relevant spec](https://tc39.es/ecma402/#sec-intl.collator.prototype.compare) 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](https://tc39.es/ecma402/#sec-intl.collator.prototype.compare)
[MDN docs on compare method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare#using_compare_for_array_sort)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。