Skip to content

JSX4: compile error with ignored prop + prop with default value #5880

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

Closed
cknitt opened this issue Dec 7, 2022 · 1 comment · Fixed by #5881 or rescript-lang/syntax#720
Closed

JSX4: compile error with ignored prop + prop with default value #5880

cknitt opened this issue Dec 7, 2022 · 1 comment · Fixed by #5881 or rescript-lang/syntax#720

Comments

@cknitt
Copy link
Member

cknitt commented Dec 7, 2022

Tested in JSX4 automatic mode: The following code

@react.component
let make = (~priority as _, ~text="Test") => React.string(text)

results in the error

The value text can't be found

/cc @mununki

@mununki
Copy link
Member

mununki commented Dec 7, 2022

It is transformed to

  let make = (_: props<'priority, 'text>) => {
    let text = switch text {
    | Some(text) => text
    | None => "Test"
    }

    (~text="Test") => React.string(text)
  }

It should be something like

  let make = ({?text, _}: props<'priority, 'text>) => {
    let text = switch text {
    | Some(text) => text
    | None => "Test"
    }

    React.string(text)
  }

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