Description
The return types for querySelector
and querySelectorAll
(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
interface NodeSelector {
querySelector(selectors: string): Element;
querySelectorAll(selectors: string): NodeListOf<Element>;
}
But it could be expanded in the style of getElementsByTagName
:
interface NodeSelector {
querySelector(selectors: "a"): HTMLAnchorElement;
querySelector(selectors: "abbr"): HTMLPhraseElement;
...
querySelector(selectors: string): Element;
}
It's a minor convenience, but does eliminate the occasional typecast.