@@ -779,12 +779,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
779779 }
780780 }
781781
782- function emitTrailingCommaIfPresent ( nodeList : NodeArray < Node > ) : void {
783- if ( nodeList . hasTrailingComma ) {
784- write ( "," ) ;
785- }
786- }
787-
788782 function emitLinePreservingList ( parent : Node , nodes : NodeArray < Node > , allowTrailingComma : boolean , spacesBetweenBraces : boolean ) {
789783 Debug . assert ( nodes . length > 0 ) ;
790784
@@ -2451,7 +2445,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
24512445 }
24522446
24532447 function emitPrefixUnaryExpression ( node : PrefixUnaryExpression ) {
2454- const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule ( node . operand ) ;
2448+ const exportChanged = ( node . operator === SyntaxKind . PlusPlusToken || node . operator === SyntaxKind . MinusMinusToken ) &&
2449+ isNameOfExportedSourceLevelDeclarationInSystemExternalModule ( node . operand ) ;
24552450
24562451 if ( exportChanged ) {
24572452 // emit
@@ -3248,10 +3243,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
32483243 }
32493244 }
32503245
3251- function emitDownLevelForOfStatement ( node : ForOfStatement ) {
3252- emitLoop ( node , emitDownLevelForOfStatementWorker ) ;
3253- }
3254-
32553246 function emitDownLevelForOfStatementWorker ( node : ForOfStatement , loop : ConvertedLoop ) {
32563247 // The following ES6 code:
32573248 //
@@ -4289,22 +4280,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
42894280
42904281 // TODO (yuisu) : we should not have special cases to condition emitting comments
42914282 // but have one place to fix check for these conditions.
4292- if ( node . kind !== SyntaxKind . MethodDeclaration && node . kind !== SyntaxKind . MethodSignature &&
4293- node . parent && node . parent . kind !== SyntaxKind . PropertyAssignment &&
4294- node . parent . kind !== SyntaxKind . CallExpression ) {
4295- // 1. Methods will emit the comments as part of emitting method declaration
4296-
4283+ const { kind, parent } = node ;
4284+ if ( kind !== SyntaxKind . MethodDeclaration &&
4285+ kind !== SyntaxKind . MethodSignature &&
4286+ parent &&
4287+ parent . kind !== SyntaxKind . PropertyAssignment &&
4288+ parent . kind !== SyntaxKind . CallExpression &&
4289+ parent . kind !== SyntaxKind . ArrayLiteralExpression ) {
4290+ // 1. Methods will emit comments at their assignment declaration sites.
4291+ //
42974292 // 2. If the function is a property of object literal, emitting leading-comments
4298- // is done by emitNodeWithoutSourceMap which then call this function.
4299- // In particular, we would like to avoid emit comments twice in following case:
4300- // For example:
4293+ // is done by emitNodeWithoutSourceMap which then call this function.
4294+ // In particular, we would like to avoid emit comments twice in following case:
4295+ //
43014296 // var obj = {
43024297 // id:
43034298 // /*comment*/ () => void
43044299 // }
4305-
4300+ //
43064301 // 3. If the function is an argument in call expression, emitting of comments will be
4307- // taken care of in emit list of arguments inside of emitCallexpression
4302+ // taken care of in emit list of arguments inside of 'emitCallExpression'.
4303+ //
4304+ // 4. If the function is in an array literal, 'emitLinePreservingList' will take care
4305+ // of leading comments.
43084306 emitLeadingComments ( node ) ;
43094307 }
43104308
@@ -4331,12 +4329,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
43314329 }
43324330
43334331 emitSignatureAndBody ( node ) ;
4334- if ( modulekind !== ModuleKind . ES6 && node . kind === SyntaxKind . FunctionDeclaration && node . parent === currentSourceFile && node . name ) {
4332+ if ( modulekind !== ModuleKind . ES6 && kind === SyntaxKind . FunctionDeclaration && parent === currentSourceFile && node . name ) {
43354333 emitExportMemberAssignments ( ( < FunctionDeclaration > node ) . name ) ;
43364334 }
43374335
43384336 emitEnd ( node ) ;
4339- if ( node . kind !== SyntaxKind . MethodDeclaration && node . kind !== SyntaxKind . MethodSignature ) {
4337+ if ( kind !== SyntaxKind . MethodDeclaration && kind !== SyntaxKind . MethodSignature ) {
43404338 emitTrailingComments ( node ) ;
43414339 }
43424340 }
0 commit comments