From eda9aead1149abc0c12fd33f5f9ab03e8b89d469 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 20 Aug 2015 16:21:58 -0700 Subject: [PATCH] Add comments --- src/compiler/emitter.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b524f37d47e..4b85f22e7ca 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6922,13 +6922,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } + /** + * Filter comment when removeComments is true according to following rules: + * - Pinned Comments - remove all but the top of the file one + * - Normal Comments - remove all + * - // Comments - remove all + * @param isTopOfFileComments boolean indicating whether comments are at the top of file + * @param isEmittedNode boolean indicating whether node associated with the comments will be + * emitted in javascript file + */ function filterComments(ranges: CommentRange[], isTopOfFileComments: boolean, isEmittedNode=true): CommentRange[] { - // TODO (yuisu): comment if (compilerOptions.removeComments) { + // Only preserve pinned comments at the top of the file ranges = isTopOfFileComments ? filter(ranges, isPinnedComments) : []; } else { if (!isEmittedNode) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted ranges = isTopOfFileComments ? filter(ranges, isTripleSlashOrPinnedComments) : filter(ranges, isPinnedComments); } }