Skip to content
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

PPX v4: mark props type in externals as @live. #6796

Merged
merged 3 commits into from
May 31, 2024

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented 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 PR marks the props type definition as @live for external components, so the dead code analysis does not complain.

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 Author

Incidentally, noticed there were no PPX v4 tests for external components in interface files. Added one in externalWithRefs.res.

Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@@ -346,22 +346,26 @@ let make_type_decls_with_core_type props_name loc core_type typ_vars =
~manifest:core_type;
]

let live_attr = ({txt = "live"; loc = Location.none}, PStr [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe we can put this in jsx_common.ml like Jsx_common.optionalAttr

@cristianoc cristianoc enabled auto-merge (squash) May 31, 2024 13:07
@cristianoc cristianoc merged commit f24afbd into master May 31, 2024
18 checks passed
@cristianoc cristianoc deleted the prop-type-externals-live branch May 31, 2024 13:11
cknitt pushed a commit that referenced this pull request 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 that referenced this pull request 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 that referenced this pull request 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 that referenced this pull request 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@react.component props record in externals not automatically marked as live
3 participants