我想在我的一个类中使用类型NodeJS.Timer
作为类型注释:
const interval: NodeJS.Timer = setInterval(this._func, 1000)
如何导入此类型? 我正在使用流程。
答案 0 :(得分:0)
Flow使用IntervalID
类型作为setInterval
/ setTimeout
函数的返回类型。您可以看到函数typedef here in the core defs。
要使用它,只需使用该类型键入interval
:
const interval: IntervalID = setInterval(this._func, 1000)