@@ -176,6 +176,74 @@ describe("unittests:: services:: PreProcessFile:", () => {
176
176
} ) ;
177
177
} ) ;
178
178
179
+ it ( "Correctly ignore commented imports following template expression" , ( ) => {
180
+ /* eslint-disable no-template-curly-in-string */
181
+ test ( "/**" + "\n" +
182
+ " * Before" + "\n" +
183
+ " * ```" + "\n" +
184
+ " * import * as a from \"a\";" + "\n" +
185
+ " * ```" + "\n" +
186
+ " */" + "\n" +
187
+ "type Foo = `${string}`;" + "\n" +
188
+ "/**" + "\n" +
189
+ " * After" + "\n" +
190
+ " * ```" + "\n" +
191
+ " * import { B } from \"b\";" + "\n" +
192
+ " * import * as c from \"c\";" + "\n" +
193
+ " * ```" + "\n" +
194
+ " */" ,
195
+ /*readImportFile*/ true ,
196
+ /*detectJavaScriptImports*/ true ,
197
+ {
198
+ referencedFiles : [ ] ,
199
+ typeReferenceDirectives : [ ] ,
200
+ libReferenceDirectives : [ ] ,
201
+ importedFiles : [ ] ,
202
+ ambientExternalModules : undefined ,
203
+ isLibFile : false
204
+ } ) ;
205
+ /* eslint-enable no-template-curly-in-string */
206
+ } ) ;
207
+
208
+ it ( "Correctly returns imports after a template expression" , ( ) => {
209
+ /* eslint-disable no-template-curly-in-string */
210
+ test ( "`${foo}`; import \"./foo\";" ,
211
+ /*readImportFile*/ true ,
212
+ /*detectJavaScriptImports*/ true ,
213
+ {
214
+ referencedFiles : [ ] ,
215
+ typeReferenceDirectives : [ ] ,
216
+ libReferenceDirectives : [ ] ,
217
+ importedFiles : [
218
+ { fileName : "./foo" , pos : 17 , end : 22 }
219
+ ] ,
220
+ ambientExternalModules : undefined ,
221
+ isLibFile : false
222
+ } ) ;
223
+ /* eslint-enable no-template-curly-in-string */
224
+ } ) ;
225
+
226
+ it ( "Correctly returns dynamic imports from template expression" , ( ) => {
227
+ /* eslint-disable no-template-curly-in-string */
228
+ test ( "`${(<div>Text `` ${} text {} " + "\n" +
229
+ "${import(\"a\")} {import(\"b\")} " + "\n" +
230
+ "${/* A comment */} ${/* import(\"ignored\") */} </div>)}`" ,
231
+ /*readImportFile*/ true ,
232
+ /*detectJavaScriptImports*/ true ,
233
+ {
234
+ referencedFiles : [ ] ,
235
+ typeReferenceDirectives : [ ] ,
236
+ libReferenceDirectives : [ ] ,
237
+ importedFiles : [
238
+ { fileName : "a" , pos : 39 , end : 40 } ,
239
+ { fileName : "b" , pos : 53 , end : 54 }
240
+ ] ,
241
+ ambientExternalModules : undefined ,
242
+ isLibFile : false
243
+ } ) ;
244
+ /* eslint-enable no-template-curly-in-string */
245
+ } ) ;
246
+
179
247
it ( "Correctly return ES6 exports" , ( ) => {
180
248
test ( "export * from \"m1\";" + "\n" +
181
249
"export {a} from \"m2\";" + "\n" +
0 commit comments