diff --git a/internal/bundler/bundler_ts_test.go b/internal/bundler/bundler_ts_test.go index bcdde9bf862..2d730302ac9 100644 --- a/internal/bundler/bundler_ts_test.go +++ b/internal/bundler/bundler_ts_test.go @@ -223,6 +223,28 @@ func TestTSDeclareConstEnum(t *testing.T) { }) } +func TestConstEnumComments(t *testing.T) { + ts_suite.expectBundled(t, bundled{ + files: map[string]string{ + "/bar.ts": ` + export const enum PRCD { + "*/%" = 14, + } + `, + "/foo.ts": ` + import { PRCD } from "./bar"; + + console.log(PRCD["*/%"]); + `, + }, + entryPaths: []string{"/foo.ts"}, + options: config.Options{ + Mode: config.ModeBundle, + AbsOutputFile: "/out.js", + }, + }) +} + func TestTSImportEmptyNamespace(t *testing.T) { ts_suite.expectBundled(t, bundled{ files: map[string]string{ diff --git a/internal/bundler/snapshots/snapshots_ts.txt b/internal/bundler/snapshots/snapshots_ts.txt index a0bf09178c9..49ff10f6b79 100644 --- a/internal/bundler/snapshots/snapshots_ts.txt +++ b/internal/bundler/snapshots/snapshots_ts.txt @@ -1,3 +1,9 @@ +TestConstEnumComments +---------- /out.js ---------- +// foo.ts +console.log(14); + +================================================================================ TestExportTypeIssue379 ---------- /out.js ---------- // a.ts diff --git a/internal/js_printer/js_printer.go b/internal/js_printer/js_printer.go index c28d1be42ce..cb9e2d6f0e2 100644 --- a/internal/js_printer/js_printer.go +++ b/internal/js_printer/js_printer.go @@ -2001,7 +2001,7 @@ func (p *printer) printExpr(expr js_ast.Expr, level js_ast.L, flags printExprFla } else { p.printNumber(value.Number, level) } - if !p.options.MinifyWhitespace && !p.options.MinifyIdentifiers { + if !p.options.MinifyWhitespace && !p.options.MinifyIdentifiers && !strings.Contains(name, "*/") { p.print(" /* ") p.print(name) p.print(" */")