diff --git a/CHANGELOG.md b/CHANGELOG.md index 788a99d9..0a645a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ #### :bug: Bug Fix - Fix issue where the printer would omit attributes for `->` and `|>` https://github.com/rescript-lang/syntax/pull/629 +- Fix printing of optional fiels in records https://github.com/rescript-lang/rescript-compiler/issues/5654 ## ReScript 10.0 diff --git a/src/res_outcome_printer.ml b/src/res_outcome_printer.ml index 2c544cec..00874ae6 100644 --- a/src/res_outcome_printer.ml +++ b/src/res_outcome_printer.ml @@ -526,9 +526,9 @@ and printRecordDeclRowDoc (name, mut, opt, arg) = Doc.group (Doc.concat [ - (if opt then Doc.text "?" else Doc.nil); (if mut then Doc.text "mutable " else Doc.nil); printIdentLike ~allowUident:false name; + (if opt then Doc.text "?" else Doc.nil); Doc.text ": "; printOutTypeDoc arg; ]) diff --git a/tests/oprint/expected/oprint.resi.txt b/tests/oprint/expected/oprint.resi.txt index cb282946..91acd2cb 100644 --- a/tests/oprint/expected/oprint.resi.txt +++ b/tests/oprint/expected/oprint.resi.txt @@ -486,4 +486,4 @@ type emptyObject = {.} let f: (~x: 'a=?, ~y: 'b) => option<'a> type call = CleanStart let f: (~a: int=?, unit) => int -type opt = {x: int, ?y: string} \ No newline at end of file +type opt = {x: int, y?: string} \ No newline at end of file