You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.
// minimal reproducer if relevant
page.waitFor(() => (document.querySelector('some-query') as HTMLImageElement).complete); // False-positive here
Logs
ERROR: 8:17 no-useless-cast Remove this unnecessary cast.
Expected behavior
cast is not useless because document.querySelector returns Element which has no complete attribute, so it needs to be cast to HTMLImageElement
If I delete the cast I will get Type error: Property 'complete' does not exist on type 'Element'. TS2339
The text was updated successfully, but these errors were encountered:
I am not able to reproduce this issue with TypeScript 3.4.5 . This rule just uses information from TypeScript compiler, and consequently, it will depend on the type definitions for DOM. Can you try to upgrade your TypeScript version and see if the issue persists?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I want to report a bug.
SonarTS version: 1.9.0
Node.js version: 10
TypeScript version: 3.3.3333
TSLint version: 5.13.1
Rule key: no-useless-cast
Reproducer
Logs
Expected behavior
cast is not useless because document.querySelector returns
Element
which has nocomplete
attribute, so it needs to be cast to HTMLImageElementIf I delete the cast I will get
Type error: Property 'complete' does not exist on type 'Element'. TS2339
The text was updated successfully, but these errors were encountered: