microsoft / microsoft/TypeScript

[Post-7.0] Improve readability of `Array.from` / `TypedArray.from` `mapFn` parameters

Đang mở Phù hợp với người mới
#63,832 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Possible Improvement
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ả

Currently, the `mapFn` argument of `Array.from()` is typed as `(v: T, k: number) => U`.
However, when this information is displayed in an IDE tooltip, it is difficult to grasp what values are passed to `v` and `k`.

To improve clarity, I propose changing the type definition to `(element: T, index: number) => U`, following [the description of the same method in MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from). The same applies to TypedArray.from().

Supplementary Information:
- The target file is `internal/bundled/libs/lib.es2015.iterable.d.ts#L107`.
- These changes are not intended to fix differences between 6.0 and 7.0, and according to `CONTRIBUTING.md`, the Pull Request should be submitted after the 7.0 release. I plan to submit a Pull Request for this once 7.0 is released.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại internal/bundled/libs/lib.es2015.iterable.d.ts#L107 và tìm các khai báo mapFn của Array.from và TypedArray.from. So sánh tên tham số của chúng với mô tả MDN được liên kết, sau đó xác nhận rằng cả hai khai báo đều sử dụng tên mô tả cho phần tử và chỉ mục mà không thay đổi kiểu hoặc hành vi của chúng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
tooling
Loại issue
Tái cấu trúc
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
88/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.