Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import `NodeJS.Timer` type in react-native

I want to use the type NodeJS.Timer as a type annotation in one of my classes:

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

How can I import this type? I am using flow.

like image 634
daramasala Avatar asked Mar 04 '18 09:03

daramasala


1 Answers

Flow uses the IntervalID type as the return type from the setInterval/setTimeout functions. You can see the function typedef here in the core defs.

To use it, just type interval with that type:

const interval: IntervalID = setInterval(this._func, 1000)
like image 116
James Kraus Avatar answered Oct 23 '22 08:10

James Kraus