Skip to content

bug: breaks highlighting when used & in tsx attribute #287

Closed
@aleeghb

Description

@aleeghb

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.2 (ccdd47df9b73d0a22235eb06ad4c48eb57360832)

Describe the bug

nvim displays wrong highliting when used & in tsx attribute
Screenshot 2024-03-30 190744

Steps To Reproduce/Bad Parse Tree

(program [0, 0] - [12, 0]
  (import_statement [0, 0] - [0, 26]
    (import_clause [0, 7] - [0, 12]
      (identifier [0, 7] - [0, 12]))
    source: (string [0, 18] - [0, 25]
      (string_fragment [0, 19] - [0, 24])))
  (export_statement [2, 0] - [11, 1]
    declaration: (function_declaration [2, 15] - [11, 1]
      name: (identifier [2, 24] - [2, 28])
      parameters: (formal_parameters [2, 28] - [2, 30])
      body: (statement_block [2, 31] - [11, 1]
        (return_statement [3, 2] - [10, 3]
          (parenthesized_expression [3, 9] - [10, 3]
            (jsx_element [4, 10] - [9, 19]
              open_tag: (jsx_opening_element [4, 10] - [9, 11]
                name: (identifier [4, 11] - [4, 12])
                attribute: (jsx_attribute [5, 12] - [5, 107]
                  (property_identifier [5, 12] - [5, 21])
                  (string [5, 22] - [5, 107]
                    (string_fragment [5, 23] - [5, 106])))
                attribute: (jsx_attribute [6, 12] - [6, 120]
                  (property_identifier [6, 12] - [6, 16])
                  (string [6, 17] - [6, 120]
                    (string_fragment [6, 18] - [6, 63])
                    (ERROR [6, 63] - [6, 119]
                      (identifier [6, 64] - [6, 74])
                      (identifier [6, 75] - [6, 81])
                      (identifier [6, 82] - [6, 90])
                      (identifier [6, 91] - [6, 103])
                      (identifier [6, 104] - [6, 110])
                      (identifier [6, 111] - [6, 115])
                      (identifier [6, 116] - [6, 119]))))
                attribute: (jsx_attribute [7, 12] - [7, 27]
                  (property_identifier [7, 12] - [7, 18])
                  (string [7, 19] - [7, 27]
                    (string_fragment [7, 20] - [7, 26])))
                attribute: (jsx_attribute [8, 12] - [8, 37]
                  (property_identifier [8, 12] - [8, 15])
                  (string [8, 16] - [8, 37]
                    (string_fragment [8, 17] - [8, 36]))))
              (jsx_text [9, 11] - [9, 15])
              close_tag: (jsx_closing_element [9, 15] - [9, 19]
                name: (identifier [9, 17] - [9, 18])))))))))
test.tsx           0.25 ms        1617 bytes/ms (ERROR [6, 63] - [6, 119])

Expected Behavior/Parse Tree

tree-sitter shouldn't output ERROR for valid tsx

Repro

https://www.typescriptlang.org/play?ssl=12&ssc=2&pln=1&pc=1#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgcilQ3wG4AocpAD0ljgBMlMUBXAGy1YDsNgJucABK4kACgCUcAN7k4cIjFZRBYufI2aAPCnWb9cNOxQBnEwDkUIJAF4ARJGDcYSKAFokANyTOTb7gJIcJjsNHBgxmhIbsAuIH5Rzq5wAOYoYG4ATOFuABxw7CkAXI5J7l4+MH5sMBAFxRkADHZ6BhoAFkSY9u0wMGAmRQD0Q95QUewAdGi4APysMCAA+iYQylE2aEQoLv40MG7pYABkC8vWDMCsIDZHl+5xETtIp4tLaFZgKMAp3Jvbu24+0OYDALTa+hgKCgKSQMHsSwARsZuABrcEQjREdj2AIQMA+ZIBLquIhQDEQgB8ABknKitEMUJT1BJyABfIA

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