tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter
MIT License
332 stars 103 forks source link

bug: Odd highlighting of Boolean expression? #298

Closed cmdcolin closed 1 month ago

cmdcolin commented 1 month ago

Did you check existing issues?

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

No response

Describe the bug

image

Steps To Reproduce/Bad Parse Tree

lexical_declaration [0, 0] - [0, 25]
  variable_declarator [0, 6] - [0, 25]
    name: identifier [0, 6] - [0, 7]
    value: call_expression [0, 10] - [0, 25]
      function: identifier [0, 10] - [0, 17]
      arguments: arguments [0, 17] - [0, 25]
        string [0, 18] - [0, 24]
          string_fragment [0, 19] - [0, 23]
lexical_declaration [1, 0] - [1, 37]
  variable_declarator [1, 6] - [1, 37]
    name: identifier [1, 6] - [1, 7]
    value: call_expression [1, 10] - [1, 37]
      function: member_expression [1, 10] - [1, 20]
        object: identifier [1, 10] - [1, 14]
        property: property_identifier [1, 15] - [1, 20]
      arguments: arguments [1, 20] - [1, 37]
        call_expression [1, 21] - [1, 36]
          function: identifier [1, 21] - [1, 28]
          arguments: arguments [1, 28] - [1, 36]
            string [1, 29] - [1, 35]
              string_fragment [1, 30] - [1, 34]
lexical_declaration [2, 0] - [5, 1]
  variable_declarator [2, 6] - [5, 1]
    name: identifier [2, 6] - [2, 7]
    value: object [2, 10] - [5, 1]
      pair [3, 2] - [3, 35]
        key: property_identifier [3, 2] - [3, 6]
        value: call_expression [3, 8] - [3, 35]
          function: member_expression [3, 8] - [3, 18]
            object: identifier [3, 8] - [3, 12]
            property: property_identifier [3, 13] - [3, 18]
          arguments: arguments [3, 18] - [3, 35]
            call_expression [3, 19] - [3, 34]
              function: identifier [3, 19] - [3, 26]
              arguments: arguments [3, 26] - [3, 34]
                string [3, 27] - [3, 33]
                  string_fragment [3, 28] - [3, 32]
      pair [4, 2] - [4, 35]
        key: property_identifier [4, 2] - [4, 6]
        value: call_expression [4, 8] - [4, 35]
          function: identifier [4, 8] - [4, 15]
          arguments: arguments [4, 15] - [4, 35]
            call_expression [4, 16] - [4, 34]
              function: member_expression [4, 16] - [4, 26]
                object: identifier [4, 16] - [4, 20]
                property: property_identifier [4, 21] - [4, 26]
              arguments: arguments [4, 26] - [4, 34]
                string [4, 27] - [4, 33]
                  string_fragment [4, 28] - [4, 32]

Expected Behavior/Parse Tree

i actually don't know. i also don't know the exact tree sitter version or grammar versions (?) i am using, i don't know how to get this out of neovim and :checkhealth doesn't really tell me. let me know if there are any tips

Repro

affects file with .tsx or .ts extension in neovim


const x = Boolean('true')
const y = JSON.parse(Boolean('true'))
const z = {
  wow1: JSON.parse(Boolean('true')),
  wow2: Boolean(JSON.parse('true')), //<-- on this line true is not highlighted
}

putting same code in a .js file has 'true' highlighted in wow2

amaanq commented 1 month ago

a screenshot is not anything to go off of for the parser - this is for parse issues, your issue lies in something else (highlighting implementation of whatever tool you're using that leverages tree-sitter)

cmdcolin commented 1 month ago

sorry for the noise then. the parse tree did look fine as far as i could tell, but didn't know if i missed something. will see about reporting elsewhere