TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

#1261: NodeListOf#item

Open danielrentz opened this issue 3 years ago • 7 comments

fixes #1261 NodeListOf#item() misses null in return type

danielrentz avatar Feb 22 '22 05:02 danielrentz

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

github-actions[bot] avatar Feb 22 '22 05:02 github-actions[bot]

Thanks for helping. You manipulated a generated file. The correct place would be overridingTypes.jsonc

HolgerJeromin avatar Feb 22 '22 07:02 HolgerJeromin

Oh I see, thanks for the pointer. Will take care.

danielrentz avatar Feb 22 '22 07:02 danielrentz

CLA assistant check
All CLA requirements met.

ghost avatar Feb 22 '22 08:02 ghost

I think this is intentionally done to follow the current array indexing behavior. Also pinging @orta

saschanaz avatar Feb 25 '22 12:02 saschanaz

I understand that this will not be changed for array index due to the generic behaviour of TS. But it should be done "right" for explicit methods. At least it should be consistent across the interfaces NodeList and NodeListOf. A subtle difference is that array index will return undefined while item returns null.

BTW, how will the new method Array#at behave in TS?

danielrentz avatar Feb 25 '22 15:02 danielrentz

Hrm, yeah, looks like I was a bit gung ho in https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1261

Yeah, .at will/should/does (I've not checked, but that's what we agreed on) have the undefined added in the types but we shouldn't really be switching such a popular DOM API I think (just like we didn't do it to arrays) - those sort of changes aren't really possible at the ecosystem size TS is at nowdays

orta avatar Feb 26 '22 11:02 orta