Skip to content

Parser should recover better from broken JSX prop code #6559

Closed
@zth

Description

@zth
<CompletionSupport.TestComponent on= someOtherProp=true

This is parsed as:

[
  structure_item 
    Pstr_eval
    expression 
      Pexp_apply
      expression 
        Pexp_ident "React.createElement" 
      [
        <arg>
        Nolabel
          expression 
            Pexp_ident "CompletionSupport.TestComponent.make" 
        <arg>
        Nolabel
          expression 
            Pexp_record
            [
              "on" 
                expression 
                  attribute  "res.namedArgLoc"
                    []
                  Pexp_ident "someOtherProp" 
            ]
            None
      ]
  structure_item 
    Pstr_eval
    expression 
      Pexp_construct "true" 
      None
]

...which effectively means:

<CompletionSupport.TestComponent on=someOtherProp
true

But, preferably it should be parsed as:

<CompletionSupport.TestComponent on=%rescript.exprHole someOtherProp=true

The current state prevents us from doing proper completions in this case, which is quite common, so it's a bit annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions