-
Notifications
You must be signed in to change notification settings - Fork 465
WIP - Try and transform jsx through compilation #7385
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @cristianoc, curious to hear your thoughts on this!
//cc @zth
false ) | ||
| _ -> None) | ||
in | ||
let record = Ast_helper.Exp.record fields None in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This idea here is to create a record of JsxDOM.domProps
and type-check that.
It is of course laser focused to the <div>
example.
(children
could later be checked separately, as I believe we need to check if those Jsx.element
)
let path = Path.Pdot (Path.Pident (Ident.create "Jsx"), "element", 0) in | ||
Ctype.newconstr path [] | ||
in | ||
let _typed_record = type_expect_ env record jsx_dom_type_expected in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsx_dom_type_expected
isn't quite right here. Could we maybe try and find it in the env
?
let _typed_record = type_expect_ env record jsx_dom_type_expected in | ||
{ | ||
exp_desc = | ||
Texp_jsx_container_element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We transform this node a couple of times later on, in all the phases but overall the important check happened here.
After looking at how complexity builds up, perhaps this was not the best suggestion. Thoughts? |
I agree that this touches on many layers, and the impact of breaking something is considerable. Marking the transformed application call with additional data could also be effective. I would support adding the original We could ultimately detect it in |
Super rough experiment about type-checking the new Jsx untyped nodes.
Current attempt is to compile
let x = <div className="yow"></div>
and print jsx injs_dump
.Current result: