Skip to content

Bug: ArrowFunctionExpression's generator property should always be false #8140

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Coming over from @sosukesuzuki's https://discord.com/channels/1026804805894672454/1088474511759917106/1189257356899520512:

  1. When does the generator field become true? ( )
  2. Why does the id field that is always null exist? (

Response from @Josh-Cena:

  1. Never: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-estree/src/convert.ts#L1553
    So, your two questions are actually one: why do we have useless fields on ArrowFunctionExpression?
    I believe the only reason is because rules often use ArrowFunctionExpression,FunctionDeclaration,FunctionExpression as a selector, and you don't want to prevent people from querying if (func.generator)
    But maybe others who are more familiar with the AST spec can say more

That's my understanding too.

Separately from #2726, let's add JSDoc comments in code? +1 that it's unclear.

Affected URL(s)

n/a (code comments)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: ast-specIssues related to @typescript-eslint/ast-spec

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions