如何在react-native中导入`NodeJS.Timer`类型

时间:2018-03-04 09:37:28

标签: react-native flowtype

我想在我的一个类中使用类型NodeJS.Timer作为类型注释:

const interval: NodeJS.Timer = setInterval(this._func, 1000)

如何导入此类型? 我正在使用流程。

1 个答案:

答案 0 :(得分:0)

Flow使用IntervalID类型作为setInterval / setTimeout函数的返回类型。您可以看到函数typedef here in the core defs

要使用它,只需使用该类型键入interval

const interval: IntervalID = setInterval(this._func, 1000)