microsoft / microsoft/TypeScript
[Post-7.0] Improve readability of `Array.from` / `TypedArray.from` `mapFn` parameters
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da internal/bundled/libs/lib.es2015.iterable.d.ts#L107 e individua le dichiarazioni di mapFn di Array.from e TypedArray.from. Confronta i nomi dei relativi parametri con la descrizione MDN collegata, quindi conferma che entrambe le dichiarazioni usano nomi descrittivi per l'elemento e l'indice senza modificarne i tipi o il comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Refactoring
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 88/100