-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
querySelector return type could be more specific for single-element selectors #8114
querySelector return type could be more specific for single-element selectors #8114
Comments
PRs welcomed. here is some instructions on submitting lib.d.ts PRs: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes |
I'm a vanilla Javascript user but I benefit from this in VS Intellisense. So, I don't know TS well enough to answer my question: would it be possible to implement this with regex or partial-string matching, such that |
Pattern matching of overloads is #165 and it being applied to |
OK, I think that fills in the blanks of the Typescript syntax I was missing. I asked on StackOverflow about good ways to handle this in the short term, and I'm happy enough with the answer, but returning a more specific type (eventually) would make for better code. |
The return types for
querySelector
andquerySelectorAll
(in the lib.es6.d.ts) could provide more specific return type information when the selector a single element selector for a known element type.I.e., right now the types are
But it could be expanded in the style of
getElementsByTagName
:It's a minor convenience, but does eliminate the occasional typecast.
The text was updated successfully, but these errors were encountered: