File tree Expand file tree Collapse file tree
tests/baselines/reference/transformApi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1245,6 +1245,7 @@ namespace ts {
12451245 const statement = createExpressionStatement ( transformInitializedProperty ( property , receiver ) ) ;
12461246 setSourceMapRange ( statement , moveRangePastModifiers ( property ) ) ;
12471247 setCommentRange ( statement , property ) ;
1248+ setOriginalNode ( statement , property ) ;
12481249 statements . push ( statement ) ;
12491250 }
12501251 }
@@ -1262,6 +1263,7 @@ namespace ts {
12621263 startOnNewLine ( expression ) ;
12631264 setSourceMapRange ( expression , moveRangePastModifiers ( property ) ) ;
12641265 setCommentRange ( expression , property ) ;
1266+ setOriginalNode ( expression , property ) ;
12651267 expressions . push ( expression ) ;
12661268 }
12671269
Original file line number Diff line number Diff line change @@ -334,6 +334,29 @@ export {Value};
334334 }
335335 } ) . outputText ;
336336 } ) ;
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+ } ) ;
337360 } ) ;
338361}
339362
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