docs: function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
          var leadingComments;
          var currentDetachedCommentInfo;
          if (removeComments) {
              // removeComments is true, only reserve pinned comment at the top of file
              // For example:
              //      /*! Pinned Comment */
              //
              //      var x = 10;
              if (node.pos === 0) {
                  leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment);
              }
          }
          else {
              // removeComments is false, just get detached as normal and bypass the process to filter comment
              leadingComments = ts.getLeadingCommentRanges(text, node.pos);
          }
          if (leadingComments) {
              var detachedComments = [];
              var lastComment = void 0;
              for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
                  var comment = leadingComments_1[_i];
                  if (lastComment) {
                      var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
                      var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
                      if (commentLine >= lastCommentLine + 2) {
                          // There was a blank line between the last comment and this comment.  This
                          // comment is not part of the copyright comments.  Return what we have so
                          // far.
                          break;
                      }
                  }
                  detachedComments.push(comment);
                  lastComment = comment;
              }
              if (detachedComments.length) {
                  // All comments look like they could have been part of the copyright header.  Make
                  // sure there is at least one blank line between it and the node.  If not, it's not
                  // a copyright header.
                  var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end);
                  var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
                  if (nodeLine >= lastCommentLine + 2) {
                      // Valid detachedComments
                      emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
                      emitComments(text, lineMap, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
                      currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
                  }
              }
          }
          return currentDetachedCommentInfo;
          function isPinnedComment(comment) {
              return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
                  text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
          }
      }