microsoft / microsoft/TypeScript
NodeList should be generic instead of having NodeListOf
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
lib Update Request
I may be missing something, but I don't see why NodeListOf exists instead of just having NodeList itself be generic. Maybe it's a vestige from a time before generic parameter defaults.
NodeList should be able to be generic with a default value of Node.
Configuration Check
afaik, this is true of all versions of lib.dom.ts. I've checked up to 5.0
Missing / Incorrect Definition
I think this should be a backwards compatible change:
interface NodeList<TNode extends Node = Node> {
readonly length: number;
item(index: number): TNode | null;
forEach(callbackfn: (value: TNode, key: number, parent: NodeList<TNode>) => void, thisArg?: any): void;
[index: number]: TNode;
}
/** @deprecated Use NodeList */
interface NodeListOf<TNode extends Node> extends NodeList<TNode> {
item(index: number): TNode;
}
Sample Code
let getDivs = (): NodeList<HTMLDivElement> => {/* ... */};
Documentation Link
N/A though removing NodeListOf would remove a type that's only present in lid.dom.d.ts, not the actual DOM APIs.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en lib.dom.ts y localiza las declaraciones de NodeList y NodeListOf. Compáralas con el valor predeterminado genérico solicitado y el alias de compatibilidad obsoleto; el trabajo estará terminado cuando NodeList admita el uso mostrado de HTMLDivElement y el código existente de NodeListOf siga siendo compatible.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- tooling
- Tipo de issue
- Refactorización
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 35/100