From 689f3831455a31c4c0b44fe398f1aa8868e8d606 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 22 Apr 2015 17:31:55 -0700 Subject: [PATCH] Added comments for 'emitNodeWorker'. --- src/compiler/emitter.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 7ab312a22aa..a85bffb42c2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4842,14 +4842,19 @@ var __param = this.__param || function(index, decorator) { return function (targ } if (node.flags & NodeFlags.Ambient) { - return emitOnlyPinnedOrTripleSlashComments(node); + emitOnlyPinnedOrTripleSlashComments(node); + return; } + // Emitting on a SourceFile is a special case; there is not necessarily + // a corresponding start/end we're interested in, and comments will be + // emitted for the end-of-file if (node.kind === SyntaxKind.SourceFile) { if (shouldEmitSourceMap) { emitSourceFileStart(node); } - return emitJavaScriptWorker(node, allowGeneratedIdentifiers); + emitJavaScriptWorker(node, allowGeneratedIdentifiers); + return; } let emitComments = shouldEmitLeadingAndTrailingComments(node); @@ -4857,7 +4862,9 @@ var __param = this.__param || function(index, decorator) { return function (targ emitLeadingComments(node); } - if (!nodeIsSynthesized(node) && shouldEmitSourceMap) { + // Only track sourcemaps on *parsed* nodes when requested. + // Synthesized nodes do not correspond to text in the original source. + if (shouldEmitSourceMap && !nodeIsSynthesized(node)) { emitStart(node); emitJavaScriptWorker(node, allowGeneratedIdentifiers); emitEnd(node);