From 30fec6b91a9524b620fbf0123f6bb9cf0c2ad684 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Fri, 20 Oct 2023 17:17:41 -0700 Subject: [PATCH] test: demonstrate redundant check in reason-react-ppx --- ppx/test/optional-arg-check.t | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ppx/test/optional-arg-check.t diff --git a/ppx/test/optional-arg-check.t b/ppx/test/optional-arg-check.t new file mode 100644 index 000000000..e03f08460 --- /dev/null +++ b/ppx/test/optional-arg-check.t @@ -0,0 +1,34 @@ +Demonstrate how to use the React JSX PPX + + $ cat > dune-project < (lang dune 3.8) + > (using melange 0.1) + > EOF + + $ cat > dune < (melange.emit + > (target output) + > (alias mel) + > (emit_stdlib false) + > (libraries reason-react) + > (preprocess (pps melange.ppx reason-react-ppx))) + > EOF + + $ cat > x.re < 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]