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:

Building a Full-Featured Laravel Admin Dashboard with Filament

Building a full-featured Laravel admin dashboard with Filament

Build scalable admin dashboards with Filament and Laravel using Form Builder, Notifications, and Actions for clean, interactive panels.

Kayode Adeniyi
Dec 20, 2024 ⋅ 5 min read
Working With URLs In JavaScript

Working with URLs in JavaScript

Break down the parts of a URL and explore APIs for working with them in JavaScript, parsing them, building query strings, checking their validity, etc.

Joe Attardi
Dec 19, 2024 ⋅ 6 min read
Lazy Loading Vs. Eager Loading

Lazy loading vs. Eager loading

In this guide, explore lazy loading and error loading as two techniques for fetching data in React apps.

Njong Emy
Dec 18, 2024 ⋅ 5 min read
Deno logo over an orange background

How to migrate your Node.js app to Deno 2.0

Deno is a popular JavaScript runtime, and it recently launched version 2.0 with several new features, bug fixes, and improvements […]

Yashodhan Joshi
Dec 17, 2024 ⋅ 7 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