rescript-compiler
rescript-compiler copied to clipboard
No warning on unused but initialised parameters in React components
When declaring a React component, unused but initialised parameters don't get the warning flag "unused variable xxx"
@react.component
let make = (
~unused1, // unused variable unused1.
~unsused2=true,
~unused3=?, // unused variable unused3.
~text=?
) => {
<div> {React.string(text->Option.getOr(""))} </div>
}
If it's a "regular" function, the same parameter gets the warning
let foo = (
~unused1, // unused variable unused1.
~unsused2=true, // unused variable unsused2.
~unused3=?, // unused variable unused3.
~text=?) =>
text->Option.getOr("")
Using the playground, it seems the bug appeared with v10.1.2 and is still there for v11.x and v12.x
I believe this is because the JSX v4 emits a switch for the default param case, although not sure. cc @mununki
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.