@@ -2639,9 +2639,6 @@ namespace ts {
26392639 /**
26402640 * Records that a declaration was emitted in the current scope, if it was the first
26412641 * declaration for the provided symbol.
2642- *
2643- * NOTE: if there is ever a transformation above this one, we may not be able to rely
2644- * on symbol names.
26452642 */
26462643 function recordEmittedDeclarationInScope ( node : Node ) {
26472644 const name = node . symbol && node . symbol . escapedName ;
@@ -2657,18 +2654,22 @@ namespace ts {
26572654 }
26582655
26592656 /**
2660- * Determines whether a declaration is the first declaration with the same name emitted
2661- * in the current scope.
2657+ * Determines whether a declaration is *could* be the first declaration with
2658+ * the same name emitted in the current scope. Only returns false if we are absolutely
2659+ * certain a previous declaration has been emitted.
26622660 */
2663- function isFirstEmittedDeclarationInScope ( node : Node ) {
2661+ function isPotentiallyFirstEmittedDeclarationInScope ( node : Node ) {
2662+ // If the node has a named symbol, then we have enough knowledge to determine
2663+ // whether a prior declaration has been emitted.
26642664 if ( currentScopeFirstDeclarationsOfName ) {
26652665 const name = node . symbol && node . symbol . escapedName ;
26662666 if ( name ) {
26672667 return currentScopeFirstDeclarationsOfName . get ( name ) === node ;
26682668 }
26692669 }
26702670
2671- return false ;
2671+ // Otherwise, we can't be sure. For example, this node could be synthetic.
2672+ return true ;
26722673 }
26732674
26742675 /**
@@ -2690,7 +2691,7 @@ namespace ts {
26902691 setOriginalNode ( statement , node ) ;
26912692
26922693 recordEmittedDeclarationInScope ( node ) ;
2693- if ( isFirstEmittedDeclarationInScope ( node ) ) {
2694+ if ( isPotentiallyFirstEmittedDeclarationInScope ( node ) ) {
26942695 // Adjust the source map emit to match the old emitter.
26952696 if ( node . kind === SyntaxKind . EnumDeclaration ) {
26962697 setSourceMapRange ( statement . declarationList , node ) ;
0 commit comments