Skip to content

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

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
zth opened this issue May 28, 2024 · 1 comment · Fixed by rescript-lang/rescript#6796

Comments

@zth
Copy link
Collaborator

zth commented May 28, 2024

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 added a commit to rescript-lang/rescript that referenced this issue May 30, 2024
Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.
cristianoc added a commit to rescript-lang/rescript that referenced this issue May 30, 2024
Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.
@cristianoc
Copy link
Collaborator

cristianoc commented May 30, 2024

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: rescript-lang/rescript#6796

cristianoc added a commit to rescript-lang/rescript that referenced this issue May 31, 2024
* PPX v4: mark props type in externals as `@live`.

Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.

* Update CHANGELOG.md
cknitt pushed a commit to rescript-lang/rescript that referenced this issue Jun 15, 2024
* PPX v4: mark props type in externals as `@live`.

Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.

* Update CHANGELOG.md
cknitt pushed a commit to rescript-lang/rescript that referenced this issue Jun 16, 2024
* PPX v4: mark props type in externals as `@live`.

Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.

* Update CHANGELOG.md
cknitt pushed a commit to rescript-lang/rescript that referenced this issue Jun 16, 2024
* PPX v4: mark props type in externals as `@live`.

Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.

* Update CHANGELOG.md
cknitt pushed a commit to rescript-lang/rescript that referenced this issue Jun 16, 2024
* PPX v4: mark props type in externals as `@live`.

Fixes rescript-lang/rescript-vscode#994

Dead code elimination in the editor tooling complains about props never being read in the `props` type record defined by the V4 ppx.
This is because externals don't provide the implementation of the component, and it's in the implementation that props could be read.
This OR marks the `props` type definition as `@live` for external components, so the dead code analysis does not fire.

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants