Skip to content

Commit

Permalink
test: demonstrate redundant check in reason-react-ppx
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Oct 21, 2023
1 parent be16181 commit 30fec6b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ppx/test/optional-arg-check.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Demonstrate how to use the React JSX PPX

$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using melange 0.1)
> EOF

$ cat > dune <<EOF
> (melange.emit
> (target output)
> (alias mel)
> (emit_stdlib false)
> (libraries reason-react)
> (preprocess (pps melange.ppx reason-react-ppx)))
> EOF

$ cat > x.re <<EOF
> module App = {
> [@react.component]
> let make = (~myProp: bool=?) => React.null;
> };
> EOF

$ dune build @mel
File "x.re", line 3, characters 15-27:
3 | let make = (~myProp: bool=?) => React.null;
^^^^^^^^^^^^
Warning 22 [preprocessor]: react-jsx-ppx: optional argument annotations must have an explicit `option` type. Did you mean `option(bool)=?`?
File "x.re", line 3, characters 15-27:
3 | let make = (~myProp: bool=?) => React.null;
^^^^^^^^^^^^
Error: This pattern matches values of type bool
but a pattern was expected which matches values of type 'a option
[1]

0 comments on commit 30fec6b

Please sign in to comment.