microsoft / microsoft/TypeScript
Intl.Collator#compare method type does not match spec
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
### ⚙ 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)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.