Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 046bf63

Browse files
committed
Clean up name, Remove another specialized Js.t printer logic
The removal of this printer logic fixes a bug where `type a = @b Js.t<{"a": b}>`, when printed, loses the attribute
1 parent 2cd9126 commit 046bf63

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/res_printer.ml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1426,15 +1426,15 @@ and printTypExpr (typExpr : Parsetree.core_type) cmtTbl =
14261426

14271427
(* object printings *)
14281428
| Ptyp_object (fields, openFlag) ->
1429-
printBsObjectSugar ~inline:false fields openFlag cmtTbl
1429+
printObject ~inline:false fields openFlag cmtTbl
14301430
| Ptyp_constr(longidentLoc, [{ptyp_desc = Ptyp_object (fields, openFlag)}]) ->
14311431
(* for foo<{"a": b}>, when the object is long and needs a line break, we
14321432
want the <{ and }> to stay hugged together *)
14331433
let constrName = printLidentPath longidentLoc cmtTbl in
14341434
Doc.concat([
14351435
constrName;
14361436
Doc.lessThan;
1437-
printBsObjectSugar ~inline:true fields openFlag cmtTbl;
1437+
printObject ~inline:true fields openFlag cmtTbl;
14381438
Doc.greaterThan;
14391439
])
14401440

@@ -1641,8 +1641,7 @@ and printTypExpr (typExpr : Parsetree.core_type) cmtTbl =
16411641
)
16421642
in
16431643
let shouldPrintItsOwnAttributes = match typExpr.ptyp_desc with
1644-
| Ptyp_arrow _ (* es6 arrow types print their own attributes *)
1645-
| Ptyp_constr({txt = Longident.Ldot(Longident.Lident "Js", "t")}, _) -> true
1644+
| Ptyp_arrow _ (* es6 arrow types print their own attributes *) -> true
16461645
| _ -> false
16471646
in
16481647
let doc = begin match typExpr.ptyp_attributes with
@@ -1658,7 +1657,7 @@ and printTypExpr (typExpr : Parsetree.core_type) cmtTbl =
16581657
in
16591658
printComments doc cmtTbl typExpr.ptyp_loc
16601659

1661-
and printBsObjectSugar ~inline fields openFlag cmtTbl =
1660+
and printObject ~inline fields openFlag cmtTbl =
16621661
let doc = match fields with
16631662
| [] -> Doc.concat [
16641663
Doc.lbrace;

0 commit comments

Comments
 (0)