-
Notifications
You must be signed in to change notification settings - Fork 38
Fix jsx V4 issue with type constraints and components names other than "make". #617
Conversation
I think the code is correct, and can be cleaned up later (in one place, the constraint is used to determine the type of props, an in a different place of the ppx, the already used constraint is now removed). |
Sorry for making confusion. |
I think what's needed is a parsing test, see how the 2 cases in the example are parsed differently. |
Got it, added. |
There's no reason the 2 examples should be treated differently. This looks like a parsing issue. |
Yes, it is. The difference between V3 and V4 for this case is the location of prop value. In V3, it is used as value for labeled argument, instead in V4, it is used as value for a field in record. In my guess, the parsing issue occurs due to where it is used. |
Not sure what's going on. Parsing is done once it reaches the ppx. |
OK so here's a real self-contained example, which I think was the intended example: let optionMap = (x, f) =>
switch x {
| None => None
| Some(v) => Some(f(v))
}
module Parens = {
@react.component
let make = (~id=?) => {
<div id=?{id->optionMap(x => x)} />
}
} |
Going forward, I think it's more efficient to take a look directly at the project that does not compile, instead of trying to extract examples. |
@mattdamon108 thanks for the great work on all of this. |
I think I didn't exactly understand what |
It won't happen without your help and lead. You might remember my first suggestion was just the spread props support. 😆 Thank you for all of this. |
Better split up PRs in small ones. Will merge this. |
Fix issues in #615