2023-06-19
1703
#typescript
Debjyoti Banerjee
171799
104
Jun 19, 2023 ⋅ 6 min read

Understanding TypeScript generators

Debjyoti Banerjee I'm Debjyoti, software engineer and game developer. Currently exploring JavaScript and Flutter, and trying to come up with solutions to problems in the healthcare sector. Love open source.

Recent posts:

TypeScript logo over a pink and white background.

Drizzle vs. Prisma: Which ORM is best for your project?

Compare Prisma and Drizzle ORMs to learn their differences, strengths, and weaknesses for data access and migrations.

Temitope Oyedele
Nov 21, 2024 ⋅ 10 min read
Practical Implementation Of The Rule Of Least Power For Developers

Practical implementation of the Rule of Least Power for developers

It’s easy for devs to default to JavaScript to fix every problem. Let’s use the RoLP to find simpler alternatives with HTML and CSS.

Timonwa Akintokun
Nov 21, 2024 ⋅ 8 min read
Rust logo over black marble background.

Handling memory leaks in Rust

Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.

Ukeje Goodness
Nov 20, 2024 ⋅ 4 min read
Robot pretending to be a person.

Using curl-impersonate in Node.js to avoid blocks

Bypass anti-bot measures in Node.js with curl-impersonate. Learn how it mimics browsers to overcome bot detection for web scraping.

Antonello Zanini
Nov 20, 2024 ⋅ 13 min read
View all posts

5 Replies to "Understanding TypeScript generators"

  1. An obscure feature of a language that has much bigger issues to deal with first. This is probably the fifth article I read about it, but I’ve never seen anyone actually use it in the wild, including me.

    1. I agree. And it’s gimmicky.
      As an article, it’s good; but as a dev pattern I could imagine one of my junior, programmers burning up hours—or even days or weeks—looking for clever ways to use this feature (a “clever” solution looking for the ideal problem) …only to have the next maintainer come along and rip it out for something more straightforward.

  2. I think this next() call:

    console.log(generator.next()); // Uncaught Error: Something went wrong

    Is not correct. That error doesn’t get thrown out of the generator because it is caught within the generator.

  3. Generators are a JavaScript language feature, not a Typescript feature. How can we take the author seriously if he doesn’t even know the most fundamental fact about the topic he’s discussing

    1. I think you need to chill out. It IS technically a feature in typescript too, as TS supports whatever JS supports, but really, does an author have to state the obvious for it to be taken seriously? Maybe people learn TS and not JS, or, maybe people don’t care.

Leave a Reply