microsoft / microsoft/TypeScript
HTMLCollection should be string indexable
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
According to MDN, HTMLCollection should be string indexable:
HTMLCollection also exposes its members directly as properties by both name and index. HTML IDs may contain : and . as valid characters, which would necessitate using bracket notation for property access. Currently HTMLCollections does not recognize purely numeric IDs, which would cause conflict with the array-style access, though HTML5 does permit these.
TypeScript Version: master
Code
declare const elements: HTMLCollection;
elements['myId'] // implicit any error, where it should be the same type as elements[0].
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the HTMLCollection declaration in TypeScript's standard library definitions and compare its numeric and named property access. Use the issue's code example to verify that string indexing produces the same element type as numeric indexing; done means the purely named access no longer reports an implicit any error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, typescript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100