Instead of threading locations to the make function that is ultimately passed to createElement (which is what was originally triggering the error) we wrap the result of "ml_component" (the implementation provided by user) with : React.element annotation.
Then, the error happens earlier, in code that is not generated by ppx but written by user.
Tested manually (idk how to test ppx with full typed compilation 😅 ):
File "example/src/HelloWorldOCaml.ml", line 5, characters 26-38:
5 | let%component make ~foo = [React.null]
^^^^^^^^^^^^
Error: This expression has type 'a list
but an expression was expected of type React.element
File "example/src/HelloWorldOCaml.ml", line 5, characters 24-36:
5 | let%component make () = [React.null]
^^^^^^^^^^^^
Error: This expression has type 'a list
but an expression was expected of type React.element
Fixes #90.
Instead of threading locations to the
make
function that is ultimately passed tocreateElement
(which is what was originally triggering the error) we wrap the result of "ml_component" (the implementation provided by user) with: React.element
annotation.Then, the error happens earlier, in code that is not generated by ppx but written by user.
Tested manually (idk how to test ppx with full typed compilation 😅 ):