Skip to main content
 首页 » 编程设计

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

2025年05月04日91mengfanrong

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

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

如何导入这种类型?
我正在使用流量。

请您参考如下方法:

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

要使用它,只需输入 interval使用这种类型:

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