Skip to content

Jsx parsing error where using hyphen prop name #6723

Closed
@mununki

Description

@mununki

I've tried to use a custom data attribute for lower case jsx.

module Div = {
  type props = {
    ...JsxDOM.domProps,
    \"data-a": string,
  }
  @module("react/jsx-runtime")
  external jsx: (string, props) => Jsx.element = "jsx"

  let make = (props: props) => jsx("div", props)
}

let customDiv = <Div name="div" data-a="a" />
FAILED: src/Abstract.ast

  Syntax error!
  /Users/woonki/GitHub/projects/rescript-test/src/Abstract.res:82:37

  80 │ }
  81 │ 
  82 │ let customDiv = <Div name="div" data-a="a" />
  83 │ 

  I'm not sure what to parse here when looking at "-".

There are two workaround here.

  1. If I replace the name props after data-a, the build is fine. <Div data-a="a" name="div" />
  2. If I don't format the code and keep the prop being exotic, then the build is fine. <Div name="div" \"data-a"="a" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions