@@ -211,6 +211,7 @@ namespace ts {
211
211
emitNodeWithComments,
212
212
emitBodyWithDetachedComments,
213
213
emitTrailingCommentsOfPosition,
214
+ emitLeadingComments,
214
215
} = comments ;
215
216
216
217
let currentSourceFile : SourceFile ;
@@ -2228,6 +2229,15 @@ namespace ts {
2228
2229
2229
2230
// Write the delimiter if this is not the first node.
2230
2231
if ( previousSibling ) {
2232
+ // i.e
2233
+ // function commentedParameters(
2234
+ // /* Parameter a */
2235
+ // a
2236
+ // /* End of parameter a */ -> this comment doesn't consider to be trailing comment of parameter "a" due to newline
2237
+ // ,
2238
+ if ( emitLeadingComments && delimiter && previousSibling . end !== parentNode . end ) {
2239
+ emitLeadingComments ( previousSibling . end , /*isEmittedNode*/ previousSibling . kind !== SyntaxKind . NotEmittedStatement ) ;
2240
+ }
2231
2241
write ( delimiter ) ;
2232
2242
2233
2243
// Write either a line terminator or whitespace to separate the elements.
@@ -2274,6 +2284,20 @@ namespace ts {
2274
2284
write ( "," ) ;
2275
2285
}
2276
2286
2287
+
2288
+ // Emit any trailing comment of the last element in the list
2289
+ // i.e
2290
+ // var array = [...
2291
+ // 2
2292
+ // /* end of element 2 */
2293
+ // ];
2294
+ if ( previousSibling && delimiter && previousSibling . end !== parentNode . end ) {
2295
+ emitLeadingComments ( previousSibling . end , /*isEmittedNode*/ previousSibling . kind !== SyntaxKind . NotEmittedStatement ) ;
2296
+ if ( hasTrailingComma ) {
2297
+ emitLeadingComments ( previousSibling . end , /*isEmittedNode*/ previousSibling . kind !== SyntaxKind . NotEmittedStatement ) ;
2298
+ }
2299
+ }
2300
+
2277
2301
// Decrease the indent, if requested.
2278
2302
if ( format & ListFormat . Indented ) {
2279
2303
decreaseIndent ( ) ;
0 commit comments