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

未关闭 适合新手
#63,832 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
88/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
tooling

调研方向

从 internal/bundled/libs/lib.es2015.iterable.d.ts#L107 开始,找到 Array.from 和 TypedArray.from 的 mapFn 声明。将它们的参数命名与链接的 MDN 描述进行比较,然后确认这两个声明都使用了描述性的元素名称和索引名称,同时不改变它们的类型或行为。

由索引模型根据 Issue 内容生成。

描述

Possible Improvement

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. 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.
主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 15 小时
30 天内合并 PR
106

贡献指南

打开贡献指南

从这里开始

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

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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