diff --git a/tests/ppx/react/expected/optionalPropValue.res.txt b/tests/ppx/react/expected/optionalPropValue.res.txt new file mode 100644 index 00000000..6587b7fb --- /dev/null +++ b/tests/ppx/react/expected/optionalPropValue.res.txt @@ -0,0 +1,32 @@ +module Parens = { + type props<'id> = {key?: string, id?: 'id} + @react.component + let make = ({?id, _}: props<'id>) => { + ReactDOM.jsx( + "div", + { + id: ?{ + let _ = () + id->Option.map(x => x) + }, + }, + ) + } + let make = { + let \"OptionalPropValue$Parens" = (props: props<_>) => make(props) + \"OptionalPropValue$Parens" + } +} + +module WithoutParens = { + type props<'id> = {key?: string, id?: 'id} + + @react.component + let make = ({?id, _}: props<'id>) => { + ReactDOM.jsx("div", {id: ?id->Option.map(x => x)}) + } + let make = { + let \"OptionalPropValue$WithoutParens" = (props: props<_>) => make(props) + \"OptionalPropValue$WithoutParens" + } +} diff --git a/tests/ppx/react/optionalPropValue.res b/tests/ppx/react/optionalPropValue.res new file mode 100644 index 00000000..5ad053f5 --- /dev/null +++ b/tests/ppx/react/optionalPropValue.res @@ -0,0 +1,18 @@ +module Parens = { + @react.component + let make = (~id=?) => { +