microsoft / microsoft/TypeScript
[Post-7.0] Improve readability of `Array.from` / `TypedArray.from` `mapFn` parameters
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 internal/bundled/libs/lib.es2015.iterable.d.ts#L107 开始,找到 Array.from 和 TypedArray.from 的 mapFn 声明。将它们的参数命名与链接的 MDN 描述进行比较,然后确认这两个声明都使用了描述性的元素名称和索引名称,同时不改变它们的类型或行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- tooling
- Issue 类型
- 重构
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 88/100