@@ -1257,7 +1257,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
12571257
12581258 function emitBindingElement ( node : BindingElement ) {
12591259 if ( node . propertyName ) {
1260- emit ( node . propertyName , /*allowGeneratedIdentifiers*/ false ) ;
1260+ emitVerbatimDeclarationName ( node . propertyName ) ;
12611261 write ( ": " ) ;
12621262 }
12631263 if ( node . dotDotDotToken ) {
@@ -1605,21 +1605,21 @@ var __param = this.__param || function(index, decorator) { return function (targ
16051605 write ( "*" ) ;
16061606 }
16071607
1608- emit ( node . name , /*allowGeneratedIdentifiers*/ false ) ;
1608+ emitVerbatimDeclarationName ( node . name ) ;
16091609 if ( languageVersion < ScriptTarget . ES6 ) {
16101610 write ( ": function " ) ;
16111611 }
16121612 emitSignatureAndBody ( node ) ;
16131613 }
16141614
16151615 function emitPropertyAssignment ( node : PropertyDeclaration ) {
1616- emit ( node . name , /*allowGeneratedIdentifiers*/ false ) ;
1616+ emitVerbatimDeclarationName ( node . name ) ;
16171617 write ( ": " ) ;
16181618 emit ( node . initializer ) ;
16191619 }
16201620
16211621 function emitShorthandPropertyAssignment ( node : ShorthandPropertyAssignment ) {
1622- emit ( node . name , /*allowGeneratedIdentifiers*/ false ) ;
1622+ emitVerbatimDeclarationName ( node . name ) ;
16231623 // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example:
16241624 // module m {
16251625 // export let y;
@@ -1699,7 +1699,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
16991699 let indentedBeforeDot = indentIfOnDifferentLines ( node , node . expression , node . dotToken ) ;
17001700 write ( "." ) ;
17011701 let indentedAfterDot = indentIfOnDifferentLines ( node , node . dotToken , node . name ) ;
1702- emit ( node . name , /*allowGeneratedIdentifiers*/ false ) ;
1702+ emitVerbatimDeclarationName ( node . name ) ;
17031703 decreaseIndentIf ( indentedBeforeDot , indentedAfterDot ) ;
17041704 }
17051705
@@ -2908,7 +2908,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
29082908
29092909 function emitAccessor ( node : AccessorDeclaration ) {
29102910 write ( node . kind === SyntaxKind . GetAccessor ? "get " : "set " ) ;
2911- emit ( node . name , /*allowGeneratedIdentifiers*/ false ) ;
2911+ emitVerbatimDeclarationName ( node . name ) ;
29122912 emitSignatureAndBody ( node ) ;
29132913 }
29142914
@@ -4811,8 +4811,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
48114811 * The standard function to emit on any Node.
48124812 * This will take care of leading/trailing comments, and sourcemaps if applicable.
48134813 */
4814- function emit ( node : Node , allowGeneratedIdentifiers ?: boolean ) : void {
4815- emitNodeWorker ( node , /*shouldEmitSourceMap */ true , allowGeneratedIdentifiers ) ;
4814+ function emit ( node : Node ) : void {
4815+ emitNodeWorker ( node , /*allowGeneratedIdentifiers */ true ) ;
48164816 }
48174817
48184818 /**
@@ -4826,8 +4826,30 @@ var __param = this.__param || function(index, decorator) { return function (targ
48264826 * the sourcemap for 'a + b' itself, but if 'emit' is called instead for nodes 'a' and 'b',
48274827 * then both 'a' and 'b' will have sourcemaps recorded if appropriate.
48284828 */
4829- function emitWithoutSourceMap ( node : Node , allowGeneratedIdentifiers ?: boolean ) : void {
4830- emitNodeWorker ( node , /*shouldEmitSourceMap*/ false , allowGeneratedIdentifiers ) ;
4829+ function emitWithoutSourceMap ( node : Node ) : void {
4830+ emitNodeWorker ( node , /*shouldEmitSourceMap*/ false , /*allowGeneratedIdentifiers*/ true ) ;
4831+ }
4832+
4833+ /**
4834+ * Emits a node with comments and tracks sourcemaps for said node, disallowing the renaming
4835+ * of identifiers to be *for this node*.
4836+ *
4837+ * This is useful in scenarios when a name's usage can be non-local and it is not feasible to
4838+ * rename it (e.g. the declaration name of a property for a shorthand property).
4839+ *
4840+ * Note that preventing generated identifier renaming only applies if the given node is an
4841+ * identifier. If it is not an identifier, contained identifiers may still be replaced
4842+ * by their generated counterparts.
4843+ *
4844+ * For instance, given an the computed property '[a + b]' from below :
4845+ * var x = {
4846+ * [a + b]() {
4847+ * }
4848+ * }
4849+ * Both 'a' and 'b' may be replaced by generated counterparts in '[a + b]'.
4850+ */
4851+ function emitVerbatimDeclarationName ( node : DeclarationName ) {
4852+ emitNodeWorker ( node , /*shouldEmitSourceMap*/ true , /*allowGeneratedIdentifiers*/ false ) ;
48314853 }
48324854
48334855 /**
@@ -4836,7 +4858,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
48364858 * This function acts as a common path to 'emit' and 'emitNodeWithoutSourceMap'
48374859 * that is aware of ordering between comments and sourcemap spans.
48384860 */
4839- function emitNodeWorker ( node : Node , shouldEmitSourceMap : boolean , allowGeneratedIdentifiers ? : boolean ) : void {
4861+ function emitNodeWorker ( node : Node , shouldEmitSourceMap : boolean , allowGeneratedIdentifiers : boolean ) : void {
48404862 if ( ! node ) {
48414863 return ;
48424864 }
@@ -4923,7 +4945,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
49234945 /**
49244946 * Emits a node without emitting comments or tracking sourcemap information.
49254947 */
4926- function emitBareNode ( node : Node , allowGeneratedIdentifiers : boolean = true ) {
4948+ function emitBareNode ( node : Node , allowGeneratedIdentifiers : boolean ) {
49274949 // Check if the node can be emitted regardless of the ScriptTarget
49284950 switch ( node . kind ) {
49294951 case SyntaxKind . Identifier :
0 commit comments