File tree 5 files changed +98
-1
lines changed
src/compiler/transformers
cases/conformance/es6/templates
5 files changed +98
-1
lines changed Original file line number Diff line number Diff line change @@ -4147,7 +4147,8 @@ namespace ts {
4147
4147
// NoSubstitutionTemplateLiterals are directly emitted via emitLiteral()
4148
4148
Debug . assert ( node . templateSpans . length !== 0 ) ;
4149
4149
4150
- return node . head . text . length !== 0 || node . templateSpans [ 0 ] . literal . text . length === 0 ;
4150
+ const span = node . templateSpans [ 0 ] ;
4151
+ return node . head . text . length !== 0 || span . literal . text . length === 0 || ! ! length ( getLeadingCommentRangesOfNode ( span . expression , currentSourceFile ) ) ;
4151
4152
}
4152
4153
4153
4154
/**
Original file line number Diff line number Diff line change
1
+ //// [templateStringWithCommentsInArrowFunction.ts]
2
+ const a = 1 ;
3
+ const f1 = ( ) =>
4
+ `${
5
+ // a
6
+ a
7
+ } a`;
8
+
9
+ const f2 = ( ) =>
10
+ `${
11
+ // a
12
+ a
13
+ } `;
14
+
15
+
16
+ //// [templateStringWithCommentsInArrowFunction.js]
17
+ var a = 1 ;
18
+ var f1 = function ( ) {
19
+ return "" +
20
+ // a
21
+ a + "a" ;
22
+ } ;
23
+ var f2 = function ( ) {
24
+ return "" +
25
+ // a
26
+ a ;
27
+ } ;
Original file line number Diff line number Diff line change
1
+ === tests/cases/conformance/es6/templates/templateStringWithCommentsInArrowFunction.ts ===
2
+ const a = 1;
3
+ >a : Symbol(a, Decl(templateStringWithCommentsInArrowFunction.ts, 0, 5))
4
+
5
+ const f1 = () =>
6
+ >f1 : Symbol(f1, Decl(templateStringWithCommentsInArrowFunction.ts, 1, 5))
7
+
8
+ `${
9
+ // a
10
+ a
11
+ >a : Symbol(a, Decl(templateStringWithCommentsInArrowFunction.ts, 0, 5))
12
+
13
+ }a`;
14
+
15
+ const f2 = () =>
16
+ >f2 : Symbol(f2, Decl(templateStringWithCommentsInArrowFunction.ts, 7, 5))
17
+
18
+ `${
19
+ // a
20
+ a
21
+ >a : Symbol(a, Decl(templateStringWithCommentsInArrowFunction.ts, 0, 5))
22
+
23
+ }`;
24
+
Original file line number Diff line number Diff line change
1
+ === tests/cases/conformance/es6/templates/templateStringWithCommentsInArrowFunction.ts ===
2
+ const a = 1;
3
+ >a : 1
4
+ >1 : 1
5
+
6
+ const f1 = () =>
7
+ >f1 : () => string
8
+ >() => `${ // a a }a` : () => string
9
+
10
+ `${
11
+ >`${ // a a }a` : string
12
+
13
+ // a
14
+ a
15
+ >a : 1
16
+
17
+ }a`;
18
+
19
+ const f2 = () =>
20
+ >f2 : () => string
21
+ >() => `${ // a a }` : () => string
22
+
23
+ `${
24
+ >`${ // a a }` : string
25
+
26
+ // a
27
+ a
28
+ >a : 1
29
+
30
+ }`;
31
+
Original file line number Diff line number Diff line change
1
+ // @removeComments : false
2
+
3
+ const a = 1 ;
4
+ const f1 = ( ) =>
5
+ `${
6
+ // a
7
+ a
8
+ } a`;
9
+
10
+ const f2 = ( ) =>
11
+ `${
12
+ // a
13
+ a
14
+ } `;
You can’t perform that action at this time.
0 commit comments