Closed as not planned
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- My proposal specifically checks TypeScript syntax, or it proposes a check that requires type information to be accurate.
- My proposal is not a "formatting rule"; meaning it does not just enforce how code is formatted (whitespace, brace placement, etc).
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
#9007 was closed before I could comment there. I wasn't aware that querySelector
took a generic argument. It'd be nice if there was a lint rule that caught
document.querySelector('something') as HTMLElement
and recommended changing it to
document.querySelector<HTMLElement>('something')
And maybe this could be done in a more generic way, possibly catching all functions that accept a generic but are being cast instead?
Fail Cases
document.querySelector('div') as HTMLDivElement
Pass Cases
document.querySelector<HTMLDivElement>('div')
Additional Info
It would help with these duplicates if this was enabled in the recommended ruleset