For AI agents: the complete documentation index is available at /tc39-atlas/en/llms.txt, the full documentation bundle is available at /tc39-atlas/en/llms-full.txt, and this page is available as Markdown at /tc39-atlas/en/proposals/proposal-generator-arrow-functions.md.
  • English
  • Generator arrow functions ?

    Proposal details
    Proposal overview

    This proposal aims to provide a concise syntax for generator arrow functions, which are currently not supported. It discusses several syntax options, such as () =>* and a new generator keyword.

    Note

    The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.

    ECMAScript proposal: Generator Arrow Functions

    Authors: Sergey Rubanov

    Champion: Hemanth HM, Brendan Eich (?)

    Stage: Stage 1 of the TC39 process.

    Motivation

    Experience so far has been that people love arrow functions and generators and want a generator arrow. — Brendan Eich

    Both arrow functions and generators are available since ES2015. Often people want to use generator arrow and this proposal (which was raised years ago) should solve their needs.

    Use cases

    Possible solutions

    Discussion of future syntax: https://github.com/tc39/proposal-generator-arrow-functions/issues/2

    Arrow function syntax

    // Irregular
    () =*> ...
    
    // not the same order as in regular generator functions
    () =>* ...
    
    // also wrong order
    () *=> ...
    
    // ASI hazard
    *() => ...

    Introduce new generator keyword for both function and arrow function

    generator function() {}
    const foo = async generator function() {};
    
    class Foo {
      x = 1
      // No more ASI hazard!
      generator foo() {}
    }

    TC39 meeting notes

    Prior discussions

    Implementations

    • none yet