File tree Expand file tree Collapse file tree 4 files changed +44
-0
lines changed
tests/baselines/reference/transformApi Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1245,6 +1245,7 @@ namespace ts {
1245
1245
const statement = createExpressionStatement ( transformInitializedProperty ( property , receiver ) ) ;
1246
1246
setSourceMapRange ( statement , moveRangePastModifiers ( property ) ) ;
1247
1247
setCommentRange ( statement , property ) ;
1248
+ setOriginalNode ( statement , property ) ;
1248
1249
statements . push ( statement ) ;
1249
1250
}
1250
1251
}
@@ -1262,6 +1263,7 @@ namespace ts {
1262
1263
startOnNewLine ( expression ) ;
1263
1264
setSourceMapRange ( expression , moveRangePastModifiers ( property ) ) ;
1264
1265
setCommentRange ( expression , property ) ;
1266
+ setOriginalNode ( expression , property ) ;
1265
1267
expressions . push ( expression ) ;
1266
1268
}
1267
1269
Original file line number Diff line number Diff line change @@ -334,6 +334,29 @@ export {Value};
334
334
}
335
335
} ) . outputText ;
336
336
} ) ;
337
+
338
+ // https://github.com/Microsoft/TypeScript/issues/17594
339
+ testBaseline ( "transformAddCommentToProperties" , ( ) => {
340
+ return transpileModule ( `
341
+ // class comment.
342
+ class Clazz {
343
+ // original comment 1.
344
+ static staticProp: number = 1;
345
+ // original comment 2.
346
+ instanceProp: number = 2;
347
+ // original comment 3.
348
+ constructor(readonly field = 1) {}
349
+ }
350
+ ` , {
351
+ transformers : {
352
+ before : [ addSyntheticComment ( n => isPropertyDeclaration ( n ) || isParameterPropertyDeclaration ( n ) || isClassDeclaration ( n ) || isConstructorDeclaration ( n ) ) ] ,
353
+ } ,
354
+ compilerOptions : {
355
+ target : ScriptTarget . ES2015 ,
356
+ newLine : NewLineKind . CarriageReturnLineFeed ,
357
+ }
358
+ } ) . outputText ;
359
+ } ) ;
337
360
} ) ;
338
361
}
339
362
Original file line number Diff line number Diff line change
1
+ class X {
2
+ constructor ( ) {
3
+ // new comment!
4
+ // original comment.
5
+ this . foo = 1 ;
6
+ }
7
+ }
Original file line number Diff line number Diff line change
1
+ /*comment*/
2
+ class Clazz {
3
+ /*comment*/
4
+ constructor ( /*comment*/
5
+ field = 1 ) {
6
+ this . field = field ;
7
+ /*comment*/
8
+ this . instanceProp = 2 ;
9
+ }
10
+ }
11
+ /*comment*/
12
+ Clazz . staticProp = 1 ;
You can’t perform that action at this time.
0 commit comments