Skip to content

module body is mandatory #198

Closed
Closed
@sguillia

Description

@sguillia

Hi!

The following piece of code is invalid but it is parsed correctly:

module x

let a = 0

Here's a link to the TypeScript Playground showing that the snippet above is invalid JavaScript or TypeScript:
https://www.typescriptlang.org/play?#code/LYewJgrgNgpgBADwFBNgFzgQzgXjgBiA

The output of tree-sitter parse is the following:

(program [0, 0] - [3, 0]
  (module [0, 0] - [0, 8]
    name: (identifier [0, 7] - [0, 8]))
  (lexical_declaration [2, 0] - [2, 9]
    (variable_declarator [2, 4] - [2, 9]
      name: (identifier [2, 4] - [2, 5])
      value: (number [2, 8] - [2, 9]))))

I think body should not be optional here:

field('body', optional($.statement_block))

The issue template asks for a link to official documentation but I am not sure where to start looking

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions