Skip to content

parser: exported functions do not have ModifierKind::Export flag #640

@DonIsaac

Description

@DonIsaac

Within the AST, exported functions do not contain an exported flag.

Example

this code

export function foo() { }

turns into this AST:

{
  "type": "Program",
  "start": 0,
  "end": 24,
  "sourceType": {
    "language": {
      "typeScript": {
        "isDefinitionFile": false
      }
    },
    "moduleKind": "module",
    "variant": "jsx",
    "alwaysStrict": false
  },
  "directives": [],
  "hashbang": null,
  "body": [
    {
      "type": "ExportNamedDeclaration",
      "start": 0,
      "end": 24,
      "declaration": {
        "type": "FunctionDeclaration",
        "start": 7,
        "end": 24,
        "id": {
          "type": "BindingIdentifier",
          "start": 16,
          "end": 19,
          "name": "foo"
        },
        "expression": false,
        "generator": false,
        "async": false,
        "params": {
          "type": "FormalParameters",
          "start": 19,
          "end": 21,
          "kind": "FormalParameter",
          "items": [],
          "rest": null
        },
        "body": {
          "type": "FunctionBody",
          "start": 22,
          "end": 24,
          "directives": [],
          "statements": []
        },
        "typeParameters": null,
        "returnType": null,
        "modifiers": []
      },
      "specifiers": [],
      "source": null,
      "export_kind": {
        "type": "value"
      }
    }
  ]
}

Notice how modifiers is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-astArea - ASTA-parserArea - ParserC-bugCategory - Bug

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions