From f7273ca4b24dffbecaa5aa9926caef4d315da8db Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 22 Apr 2015 16:02:49 -0700 Subject: [PATCH] Emit comments for function declarations in a more uniform way. --- src/compiler/emitter.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f7d10efd2d6..3aa6933501c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2952,11 +2952,6 @@ var __param = this.__param || function(index, decorator) { return function (targ return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { - // Methods will emit the comments as part of emitting method declaration - emitLeadingComments(node); - } - // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { @@ -2982,9 +2977,6 @@ var __param = this.__param || function(index, decorator) { return function (targ if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments((node).name); } - if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) { - emitTrailingComments(node); - } } function emitCaptureThisForNodeIfNecessary(node: Node): void { @@ -4874,13 +4866,15 @@ var __param = this.__param || function(index, decorator) { return function (targ // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.FunctionDeclaration: case SyntaxKind.ImportDeclaration: case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ExportAssignment: return false; + case SyntaxKind.FunctionDeclaration: + return !!(node).body; + case SyntaxKind.ModuleDeclaration: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well.