Open Oloompa opened 4 years ago
This is consistent with the current behavior of arrays (see #13778) so it's perhaps awkward to change.
But current typescript behavior is not the real behavior of javascript.
@RyanCavanaugh a NodeList is not an array though. It is a NodeList, which happens to be able to be indexed (like an array), but .item
is a function that returns Element | null
per the spec: https://developer.mozilla.org/en-US/docs/Web/API/NodeList/item
This is not just awkward, it is incorrect.
TS now has | undefined
for indexed access. This should have followed that probably.
typescript version: 3.9.2
method
item()
of nodelist should return a node or null (if index out of range) (see: https://developer.mozilla.org/en-US/docs/Web/API/NodeList/item)Typescript behavior is incorrect (lib.dom.d.ts)