Skip to content

JSX4: Bug with ForwardRef's transformation output being different with or without type annotation #6714

Closed
@mununki

Description

@mununki

Original

type inputRef = {bla: string}
module ForwardRef = {
  @react.component
  let make = React.forwardRef((ref: Js.Nullable.t<React.ref<inputRef>>) => { // type annotation for ref
    React.useImperativeHandle1(
      ref,
      () => {
        bla: "bla",
      },
      [],
    )
    React.null
  })
}

Output with type annotation

type inputRef = {bla: string}
module ForwardRef = {
  type props<'ref> = {ref?: 'ref}

  let make = (_: props<React.ref<inputRef>>, ref: Js.Nullable.t<React.ref<inputRef>>) => {
    React.useImperativeHandle1(
      ref,
      () => {
        bla: "bla",
      },
      [],
    )
    React.null
  }
  let make = React.forwardRef({
    let \"Bigint$ForwardRef" = (props: props<_>, ref) => make(props, ref)

    \"Bigint$ForwardRef"
  })
}

Output without type annotation

type inputRef = {bla: string}
module ForwardRef = {
  type props<'ref> = {ref?: 'ref}

  let make = (_: props<ReactDOM.Ref.currentDomRef>, ref) => {
    React.useImperativeHandle1(
      ref,
      () => {
        bla: "bla",
      },
      [],
    )
    React.null
  }
  let make = React.forwardRef({
    let \"Bigint$ForwardRef" = (props: props<_>, ref) => make(props, ref)

    \"Bigint$ForwardRef"
  })
}

Metadata

Metadata

Assignees

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