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
The problem is that this inside the addEventListener callback refers to the XMLHttpRequest object (I believe) and not the RemoteFile class. The latter has a url property but not a status property, whereas the former has status but not url. Clearly this code isn't right!
Flow doesn't complain, though. It thinks this has type any in the event listener.
Where possible, the DOM declarations should indicate the type of this in callbacks to prevent this sort of mistake.
For example, Google's Closure Compiler provides an @this annotation. You can see an example of this in action in the declaration for Array.prototype.find.
The text was updated successfully, but these errors were encountered:
There's an error (marked with
<---
) in this snippet which Flow could potentially catch:The problem is that
this
inside theaddEventListener
callback refers to theXMLHttpRequest
object (I believe) and not theRemoteFile
class. The latter has aurl
property but not astatus
property, whereas the former hasstatus
but noturl
. Clearly this code isn't right!Flow doesn't complain, though. It thinks
this
has typeany
in the event listener.Where possible, the DOM declarations should indicate the type of
this
in callbacks to prevent this sort of mistake.For example, Google's Closure Compiler provides an
@this
annotation. You can see an example of this in action in the declaration forArray.prototype.find
.The text was updated successfully, but these errors were encountered: