Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing of type constraints in template literal substitutions #6324

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion jscomp/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,8 @@ and printConstructorDeclaration2 ~state i
printComments doc cmtTbl cd.pcd_name.loc
in
let constrArgs =
printConstructorArguments ~isDotDotDot ~state ~indent:true cd.pcd_args cmtTbl
printConstructorArguments ~isDotDotDot ~state ~indent:true cd.pcd_args
cmtTbl
in
let gadt =
match cd.pcd_res with
Expand Down Expand Up @@ -3453,6 +3454,12 @@ and printTemplateLiteral ~state expr cmtTbl =
printStringContents txt
| _ ->
let doc = printExpressionWithComments ~state expr cmtTbl in
let doc =
match Parens.expr expr with
| Parens.Parenthesized -> addParens doc
| Braced braces -> printBraces doc expr braces
| Nothing -> doc
in
Doc.group (Doc.concat [Doc.text "${"; Doc.indent doc; Doc.rbrace])
in
let content = walkExpr expr in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ let s = `

let s = `$dollar without $braces $interpolation`

let s = `${(s: string)}`

// don't sugar to one single template literal, keep the concatenation
`the sky` ++ `is blue`

Expand Down
2 changes: 2 additions & 0 deletions jscomp/syntax/tests/printer/expr/templateLiteral.res
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ let s = `

let s = `$dollar without $braces $interpolation`

let s = `${(s: string)}`

// don't sugar to one single template literal, keep the concatenation
`the sky` ++ `is blue`

Expand Down