@@ -207,6 +207,50 @@ namespace ts.projectSystem {
207
207
checkProjectActualFiles ( p , [ file1 . path , jquery . path ] ) ;
208
208
} ) ;
209
209
210
+ it ( "inferred project - type acquisition with disableFilenameBasedTypeAcquisition:true" , ( ) => {
211
+ // Tests:
212
+ // Exclude file with disableFilenameBasedTypeAcquisition:true
213
+ const jqueryJs = {
214
+ path : "/a/b/jquery.js" ,
215
+ content : ""
216
+ } ;
217
+
218
+ const messages : string [ ] = [ ] ;
219
+ const host = createServerHost ( [ jqueryJs ] ) ;
220
+ const installer = new ( class extends Installer {
221
+ constructor ( ) {
222
+ super ( host , { typesRegistry : createTypesRegistry ( "jquery" ) } , { isEnabled : ( ) => true , writeLine : msg => messages . push ( msg ) } ) ;
223
+ }
224
+ enqueueInstallTypingsRequest ( project : server . Project , typeAcquisition : TypeAcquisition , unresolvedImports : SortedReadonlyArray < string > ) {
225
+ super . enqueueInstallTypingsRequest ( project , typeAcquisition , unresolvedImports ) ;
226
+ }
227
+ installWorker ( _requestId : number , _args : string [ ] , _cwd : string , cb : TI . RequestCompletedAction ) : void {
228
+ const installedTypings : string [ ] = [ ] ;
229
+ const typingFiles : File [ ] = [ ] ;
230
+ executeCommand ( this , host , installedTypings , typingFiles , cb ) ;
231
+ }
232
+ } ) ( ) ;
233
+
234
+ const projectService = createProjectService ( host , { typingsInstaller : installer } ) ;
235
+ projectService . setCompilerOptionsForInferredProjects ( {
236
+ allowJs : true ,
237
+ enable : true ,
238
+ disableFilenameBasedTypeAcquisition : true
239
+ } ) ;
240
+ projectService . openClientFile ( jqueryJs . path ) ;
241
+
242
+ checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
243
+ const p = projectService . inferredProjects [ 0 ] ;
244
+ checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
245
+
246
+ installer . installAll ( /*expectedCount*/ 0 ) ;
247
+ host . checkTimeoutQueueLengthAndRun ( 2 ) ;
248
+ checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
249
+ // files should not be removed from project if ATA is skipped
250
+ checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
251
+ assert . isTrue ( messages . indexOf ( "No new typings were requested as a result of typings discovery" ) > 0 , "Should not request filename-based typings" ) ;
252
+ } ) ;
253
+
210
254
it ( "external project - no type acquisition, no .d.ts/js files" , ( ) => {
211
255
const file1 = {
212
256
path : "/a/b/app.ts" ,
@@ -434,6 +478,51 @@ namespace ts.projectSystem {
434
478
435
479
installer . checkPendingCommands ( /*expectedCount*/ 0 ) ;
436
480
} ) ;
481
+
482
+ it ( "external project - type acquisition with disableFilenameBasedTypeAcquisition:true" , ( ) => {
483
+ // Tests:
484
+ // Exclude file with disableFilenameBasedTypeAcquisition:true
485
+ const jqueryJs = {
486
+ path : "/a/b/jquery.js" ,
487
+ content : ""
488
+ } ;
489
+
490
+ const messages : string [ ] = [ ] ;
491
+ const host = createServerHost ( [ jqueryJs ] ) ;
492
+ const installer = new ( class extends Installer {
493
+ constructor ( ) {
494
+ super ( host , { typesRegistry : createTypesRegistry ( "jquery" ) } , { isEnabled : ( ) => true , writeLine : msg => messages . push ( msg ) } ) ;
495
+ }
496
+ enqueueInstallTypingsRequest ( project : server . Project , typeAcquisition : TypeAcquisition , unresolvedImports : SortedReadonlyArray < string > ) {
497
+ super . enqueueInstallTypingsRequest ( project , typeAcquisition , unresolvedImports ) ;
498
+ }
499
+ installWorker ( _requestId : number , _args : string [ ] , _cwd : string , cb : TI . RequestCompletedAction ) : void {
500
+ const installedTypings : string [ ] = [ ] ;
501
+ const typingFiles : File [ ] = [ ] ;
502
+ executeCommand ( this , host , installedTypings , typingFiles , cb ) ;
503
+ }
504
+ } ) ( ) ;
505
+
506
+ const projectFileName = "/a/app/test.csproj" ;
507
+ const projectService = createProjectService ( host , { typingsInstaller : installer } ) ;
508
+ projectService . openExternalProject ( {
509
+ projectFileName,
510
+ options : { allowJS : true , moduleResolution : ModuleResolutionKind . NodeJs } ,
511
+ rootFiles : [ toExternalFile ( jqueryJs . path ) ] ,
512
+ typeAcquisition : { enable : true , disableFilenameBasedTypeAcquisition : true }
513
+ } ) ;
514
+
515
+ const p = projectService . externalProjects [ 0 ] ;
516
+ projectService . checkNumberOfProjects ( { externalProjects : 1 } ) ;
517
+ checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
518
+
519
+ installer . installAll ( /*expectedCount*/ 0 ) ;
520
+ projectService . checkNumberOfProjects ( { externalProjects : 1 } ) ;
521
+ // files should not be removed from project if ATA is skipped
522
+ checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
523
+ assert . isTrue ( messages . indexOf ( "No new typings were requested as a result of typings discovery" ) > 0 , "Should not request filename-based typings" ) ;
524
+ } ) ;
525
+
437
526
it ( "external project - no type acquisition, with js & ts files" , ( ) => {
438
527
// Tests:
439
528
// 1. No typings are included for JS projects when the project contains ts files
0 commit comments