问题
不能将类型“Timeout”分配给类型“number”
Type ‘Timeout’ is not assignable to type ‘number’.
解决方案
设置类型为NodeJS.Timeout
清除时使用delete ref.timer + clearTimeout
export type TimerType = NodeJS.Timeout
current.timer = setTimeout(() => {
delete current.timer
},timeout)
原创文章,作者:端木书台,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/269311.html