Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Fix type error by Jsx.addKeyProp for the empty props #641

Merged
merged 1 commit into from
Sep 19, 2022

Conversation

mununki
Copy link
Member

@mununki mununki commented Sep 19, 2022

This PR is related to #640 (comment)

The issue is the props type is not matched in case of empty props.

module A = {
  type props = {}
}

React.createElement(A.make, Jsx.addKeyProp({}: A.props<_>, "k")) // Error
// The type A.props is not generic so expects no arguments,
// but is here applied to 1 argument(s)

The solution is using React.createElementWithKey instead of Jsx.addKeyProp.

  1. Add React.createElementWithKey rescript-lang/rescript-react@a4c31f8
  2. Add type constraint of return type for Jsx.addKeyProp Add the return type constraint for Jsx.addKeyProp rescript#5670
  3. Use 1 and 2 in the JSX ppx

instead Jsx.addKeyProp directly
@cristianoc cristianoc merged commit 882a499 into master Sep 19, 2022
@cristianoc cristianoc deleted the fix-add-key-props branch September 19, 2022 01:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants