microsoft / microsoft/TypeScript
NodeList is no more compatible with Array<Node>. Breaking change in 3.0
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
TypeScript Version: Version 3.0.3
Code
I didn't find any mentioning to this breaking change.
This code used to compile in 2.9.2:
/**
* Array based implementation of NodeList
*/
class JSArrayNodeList extends Array<Node> implements NodeList {
constructor(items?: Array<Node>) {
if (items) {
super(...items);
} else {
super();
}
}
public item(index: number): Node {
return this[index];
}
public copy(): JSArrayNodeList {
return new JSArrayNodeList(this);
}
}
In 3.0 forEach method of NodeList and Array became incompatible.
Due to this changeset: https://github.com/Microsoft/TypeScript/commit/7a7d04e126fb7c1c6074ef26657eddb0f32e4003
A solution was to add explicit forEach which delegates call to super:
/**
* Array based implementation of NodeList
*/
class JSArrayNodeList extends Array<Node> implements NodeList {
constructor(items?: Array<Node>) {
if (items) {
super(...items);
} else {
super();
}
}
public forEach(
callbackfn: ((value: Node, index: number, array: Node[]) => void) | ((value: Node, key: number, parent: NodeList) => void),
thisArg?: any): void {
// Just call Array.forEach
Array.prototype.forEach.call(thisArg, this, callbackfn);
}
public item(index: number): Node {
return this[index];
}
public copy(): JSArrayNodeList {
return new JSArrayNodeList(this);
}
}
Expected behavior:
Documentation in breaking change list.
Actual behavior:
No information about breaking change.
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
Individua la documentazione delle breaking changes di TypeScript 3.0 e verifica come vengono elencate le modifiche di compatibilità. Documenta che le firme forEach di NodeList e Array sono diventate incompatibili, includendo la versione interessata e il contesto della migrazione mostrato nell’issue. Il lavoro è completato quando la breaking change è chiaramente inclusa nell’elenco pertinente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100