@@ -336,7 +336,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
336336 let sourceMapNameIndexMap : Map < number > = { } ;
337337 let sourceMapNameIndices : number [ ] = [ ] ;
338338 function getSourceMapNameIndex ( ) {
339- return sourceMapNameIndices . length ? sourceMapNameIndices [ sourceMapNameIndices . length - 1 ] : - 1 ;
339+ return sourceMapNameIndices . length ? lastOrUndefined ( sourceMapNameIndices ) : - 1 ;
340340 }
341341
342342 // Last recorded and encoded spans
@@ -5890,13 +5890,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
58905890 }
58915891
58925892 function hasDetachedComments ( pos : number ) {
5893- return detachedCommentsInfo !== undefined && detachedCommentsInfo [ detachedCommentsInfo . length - 1 ] . nodePos === pos ;
5893+ return detachedCommentsInfo !== undefined && lastOrUndefined ( detachedCommentsInfo ) . nodePos === pos ;
58945894 }
58955895
58965896 function getLeadingCommentsWithoutDetachedComments ( ) {
58975897 // get the leading comments from detachedPos
58985898 let leadingComments = getLeadingCommentRanges ( currentSourceFile . text ,
5899- detachedCommentsInfo [ detachedCommentsInfo . length - 1 ] . detachedCommentEndPos ) ;
5899+ lastOrUndefined ( detachedCommentsInfo ) . detachedCommentEndPos ) ;
59005900 if ( detachedCommentsInfo . length - 1 ) {
59015901 detachedCommentsInfo . pop ( ) ;
59025902 }
@@ -6017,13 +6017,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
60176017 // All comments look like they could have been part of the copyright header. Make
60186018 // sure there is at least one blank line between it and the node. If not, it's not
60196019 // a copyright header.
6020- let lastCommentLine = getLineOfLocalPosition ( currentSourceFile , detachedComments [ detachedComments . length - 1 ] . end ) ;
6020+ let lastCommentLine = getLineOfLocalPosition ( currentSourceFile , lastOrUndefined ( detachedComments ) . end ) ;
60216021 let nodeLine = getLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node . pos ) ) ;
60226022 if ( nodeLine >= lastCommentLine + 2 ) {
60236023 // Valid detachedComments
60246024 emitNewLineBeforeLeadingComments ( currentSourceFile , writer , node , leadingComments ) ;
60256025 emitComments ( currentSourceFile , writer , detachedComments , /*trailingSeparator*/ true , newLine , writeComment ) ;
6026- let currentDetachedCommentInfo = { nodePos : node . pos , detachedCommentEndPos : detachedComments [ detachedComments . length - 1 ] . end } ;
6026+ let currentDetachedCommentInfo = { nodePos : node . pos , detachedCommentEndPos : lastOrUndefined ( detachedComments ) . end } ;
60276027 if ( detachedCommentsInfo ) {
60286028 detachedCommentsInfo . push ( currentDetachedCommentInfo ) ;
60296029 }
0 commit comments