Skip to content
Advertisement

How to use generator function in typescript

I am trying to use generator function in typescript. But the compiler throws error

error TS2339: Property 'next' does not exist on type

Below is an closest sample of my code.

JavaScript

Here is the playground link for the same

Advertisement

Answer

The next method exists on the generator that the function returns, not on the generator function itself.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement