diff --git a/jscomp/syntax/src/res_comments_table.ml b/jscomp/syntax/src/res_comments_table.ml index 71c2bc95d3..f2153d72b9 100644 --- a/jscomp/syntax/src/res_comments_table.ml +++ b/jscomp/syntax/src/res_comments_table.ml @@ -1799,6 +1799,9 @@ and walkCoreType typ t comments = attach t.trailing typexpr.ptyp_loc afterTyp | Ptyp_variant (rowFields, _, _) -> walkList (rowFields |> List.map (fun rf -> RowField rf)) t comments + | Ptyp_constr + ({txt = Lident "function$"}, [({ptyp_desc = Ptyp_arrow _} as desc); _]) -> + walkCoreType desc t comments | Ptyp_constr (longident, typexprs) -> let beforeLongident, _afterLongident = partitionLeadingTrailing comments longident.loc diff --git a/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt b/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt index b672ab4da0..5741dde63c 100644 --- a/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt +++ b/jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt @@ -79,3 +79,17 @@ type jsUser = /* before */ { // above age /* before age */ "age" /* after age */: /* before int */ int /* after int */, } /* after */ + +external test: ( + // comment 1 + ~int: int, + // comment 2 + ~int: int, +) => unit = "test" + +external another_test: ( + // comment 1 + int, + // comment 2 + int, +) => unit = "test" diff --git a/jscomp/syntax/tests/printer/comments/typexpr.res b/jscomp/syntax/tests/printer/comments/typexpr.res index 296ad2ff8b..9cb8c16134 100644 --- a/jscomp/syntax/tests/printer/comments/typexpr.res +++ b/jscomp/syntax/tests/printer/comments/typexpr.res @@ -64,3 +64,17 @@ type jsUser = /* before */ { // above age /* before age */"age" /* after age */: /*before int */ int /*after int */ } /* after */ + +external test: ( + // comment 1 + ~int: int, + // comment 2 + ~int: int, +) => unit = "test" + +external another_test: ( + // comment 1 + int, + // comment 2 + int, +) => unit = "test"