Skip to content

AST tightening: TSDeclareFunction has no body, declare function cannot have async or * #9219

@Josh-Cena

Description

@Josh-Cena

Suggestion

In #9211: we are planning to enforce the following invariants in our AST for TSDeclareFunction:

  • body must be undefined, so the following is a parsing error:
    declare function foo() {}
    (I don't think it's possible to have declare: false and a body anyway, since that would be a normal function declaration)
  • If declare: true, then async and generator are both false:
    declare async function foo();
    declare function *foo();

@sosukesuzuki @fisker Do these look safe to you?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureenhancementNew feature or requestlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions