Skip to content

Commit

Permalink
Add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rtsao committed Aug 21, 2020
1 parent 1bf97e6 commit 10f6838
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ const (
forbidCall = 1 << iota
forbidIn
hasNonOptionalChainParent
wrapRequireCall
)

func (p *printer) printUndefined(level ast.L) {
Expand Down Expand Up @@ -1290,7 +1291,7 @@ func (p *printer) printExpr(expr ast.Expr, level ast.L, flags int) {
p.printSpaceBeforeIdentifier()
p.print("new")
p.printSpace()
p.printExpr(e.Target, ast.LNew, forbidCall)
p.printExpr(e.Target, ast.LNew, forbidCall | wrapRequireCall)

// TODO: Omit this while minifying
p.print("(")
Expand Down Expand Up @@ -1363,7 +1364,7 @@ func (p *printer) printExpr(expr ast.Expr, level ast.L, flags int) {
}

case *ast.ERequire:
wrap := level >= ast.LNew
wrap := level >= ast.LNew || (flags&wrapRequireCall) != 0
if wrap {
p.print("(")
}
Expand Down

0 comments on commit 10f6838

Please sign in to comment.