6

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.

4

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.