Skip to content

Commit 1ae1771

Browse files
authored
Add comment emit to printer (#677)
1 parent ffa0582 commit 1ae1771

File tree

7,787 files changed

+37062
-67880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,787 files changed

+37062
-67880
lines changed

Herebyfile.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ function baselineAcceptTask(localBaseline, refBaseline) {
392392
for (const p of toDelete) {
393393
const out = localPathToRefPath(p).replace(/\.delete$/, "");
394394
await rimraf(out);
395+
await rimraf(p); // also delete the .delete file so that it no longer shows up in a diff tool.
395396
}
396397
};
397398
}

internal/ast/ast.go

+26-1
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,10 @@ func (n *Node) AsEnumDeclaration() *EnumDeclaration {
13051305
return n.data.(*EnumDeclaration)
13061306
}
13071307

1308+
func (n *Node) AsNotEmittedStatement() *NotEmittedStatement {
1309+
return n.data.(*NotEmittedStatement)
1310+
}
1311+
13081312
func (n *Node) AsJSDoc() *JSDoc {
13091313
return n.data.(*JSDoc)
13101314
}
@@ -3444,7 +3448,28 @@ func IsModuleDeclaration(node *Node) bool {
34443448
return node.Kind == KindModuleDeclaration
34453449
}
34463450

3447-
// ModuleEqualsDeclaration
3451+
// NotEmittedStatement
3452+
3453+
// Represents a statement that is elided as part of a transformation to emit comments on a
3454+
// not-emitted node.
3455+
type NotEmittedStatement struct {
3456+
StatementBase
3457+
}
3458+
3459+
func (f *NodeFactory) NewNotEmittedStatement() *Node {
3460+
data := &NotEmittedStatement{}
3461+
return newNode(KindNotEmittedStatement, data, f.hooks)
3462+
}
3463+
3464+
func (node *NotEmittedStatement) Clone(f *NodeFactory) *Node {
3465+
return cloneNode(f.NewNotEmittedStatement(), node.AsNode(), f.hooks)
3466+
}
3467+
3468+
func IsNotEmittedStatement(node *Node) bool {
3469+
return node.Kind == KindNotEmittedStatement
3470+
}
3471+
3472+
// ImportEqualsDeclaration
34483473

34493474
type ImportEqualsDeclaration struct {
34503475
StatementBase

internal/compiler/emitter.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ func (e *emitter) emitJsFile(sourceFile *ast.SourceFile, jsFilePath string, sour
110110
}
111111

112112
printerOptions := printer.PrinterOptions{
113-
NewLine: options.NewLine,
114-
NoEmitHelpers: options.NoEmitHelpers.IsTrue(),
113+
NewLine: options.NewLine,
114+
NoEmitHelpers: options.NoEmitHelpers.IsTrue(),
115+
RemoveComments: options.RemoveComments.IsTrue(),
115116
// !!!
116117
}
117118

0 commit comments

Comments
 (0)