rescript-lang / rescript-vscode

Official VSCode plugin for ReScript
MIT License
327 stars 55 forks source link

@react.component props record in externals not automatically marked as live #994

Closed zth closed 3 months ago

zth commented 3 months ago

Bind an external component:

module StyledItemsList = {
  @module("./styles") @react.component
  external make: (~children: React.element, unit) => React.element = "StyledItemsList"
}

Use it with children:

<StyledItemsList>
      {React.string("Hello")}
</StyledItemsList>

It's still reported as:

StyledItemsList.props.children is a record label never used to read a value

But I assume it should be automatically marked as live because it's sent into an external.

cristianoc commented 3 months ago

This warning is legit, as the PPX V4 code generated for externals never reads the fields in the prop type: using it with children only amounts to creating a new record {props: ...}, not reading its fields. (An implementation would need to read them, but the implementation is exactly what's missing in an external). Can be handled at the PPX V4 level by adding a @live annotation: https://github.com/rescript-lang/rescript-compiler/pull/6796