2017-04-13 38 views
0

tryflow试试这个:为什么Flow在我听XHR错误时抱怨?

const xhr = new XMLHttpRequest(); 

xhr.addEventListener('error', (err: Error) => { 
    console.log('xhr failed', err); 
}); 

Flow让这个神秘的错误:

call of method `addEventListener`. Function cannot be called on any member of intersection type intersection 

投诉消失,如果我不采取err参数。但我需要这个参数。

我试过了,没有注释err。我究竟做错了什么?

回答

0

error事件处理函数的参数是一个Event对象,而不是Error对象。做

xhr.addEventListener('error', (err: Event) => { 
相关问题