Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: method_definition decorators should be inside the method_definition node #309

Open
1 of 2 tasks
mclaughlinconnor opened this issue Aug 25, 2024 · 0 comments · May be fixed by #310
Open
1 of 2 tasks

bug: method_definition decorators should be inside the method_definition node #309

mclaughlinconnor opened this issue Aug 25, 2024 · 0 comments · May be fixed by #310
Labels

Comments

@mclaughlinconnor
Copy link

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-typescript

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.22.6 (b40f342067a89cd6331bf4c27407588320f3c263)

Describe the bug

Parsing code where a decorator is attached to a method definition puts the (decorator) inside the class nearby to the (method_definition) instead of being inside the (method_definition) like I'd expect it to be. Other similar situations (e.g., (class_declaration), (_parameter_name), (public_field_definition)) have the decorator inside the decorated node.

The typescript AST also has the decorator inside of the method definition

https://ts-ast-viewer.com/#code/MYGwhgzhAEBiD29oG8BQ1oAEBOBTMAJvAHYgCe0AZogEJjYAUAlCgL6rtA

Steps To Reproduce/Bad Parse Tree

Trying to parse:

class Foo {
  @readonly fooBar() {}
}

Will produce:

(program
  (class_declaration
    (type_identifier)
    (class_body
      (decorator
        (identifier))
      (method_definition
        (property_identifier)
        (formal_parameters)
        (statement_block)))))

Expected Behavior/Parse Tree

I'd expect the parse tree to look like this

(program
  (class_declaration
    (type_identifier)
    (class_body
      (method_definition
        (decorator
          (identifier))
        (property_identifier)
        (formal_parameters)
        (statement_block)))))

Repro

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant