首页 > 其他分享> > Typescript 定时器类型异常 不能将类型“Timeout”分配给类型“number” Type 'Timeout' is not assignable to type
Typescript 定时器类型异常 不能将类型“Timeout”分配给类型“number” Type 'Timeout' is not assignable to type
作者:互联网
问题
不能将类型“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)
标签:type,number,timer,Timeout,类型,Type 来源: https://www.cnblogs.com/ltfxy/p/16395287.html