@@ -110,7 +110,7 @@ namespace ts.server {
110
110
111
111
export interface TypesMapFile {
112
112
typesMap : SafeList ;
113
- simpleMap : string [ ] ;
113
+ simpleMap : { [ libName : string ] : string } ;
114
114
}
115
115
116
116
/**
@@ -374,6 +374,7 @@ namespace ts.server {
374
374
375
375
private readonly hostConfiguration : HostConfiguration ;
376
376
private safelist : SafeList = defaultTypeSafeList ;
377
+ private legacySafelist : { [ key : string ] : string } = { } ;
377
378
378
379
private changedFiles : ScriptInfo [ ] ;
379
380
private pendingProjectUpdates = createMap < Project > ( ) ;
@@ -426,9 +427,12 @@ namespace ts.server {
426
427
this . toCanonicalFileName = createGetCanonicalFileName ( this . host . useCaseSensitiveFileNames ) ;
427
428
this . throttledOperations = new ThrottledOperations ( this . host , this . logger ) ;
428
429
429
- if ( opts . typesMapLocation ) {
430
+ if ( this . typesMapLocation ) {
430
431
this . loadTypesMap ( ) ;
431
432
}
433
+ else {
434
+ this . logger . info ( "No types map provided; using the default" ) ;
435
+ }
432
436
433
437
this . typingsInstaller . attach ( this ) ;
434
438
@@ -518,10 +522,12 @@ namespace ts.server {
518
522
}
519
523
// raw is now fixed and ready
520
524
this . safelist = raw . typesMap ;
525
+ this . legacySafelist = raw . simpleMap ;
521
526
}
522
527
catch ( e ) {
523
528
this . logger . info ( `Error loading types map: ${ e } ` ) ;
524
529
this . safelist = defaultTypeSafeList ;
530
+ this . legacySafelist = { } ;
525
531
}
526
532
}
527
533
@@ -1393,7 +1399,7 @@ namespace ts.server {
1393
1399
return false ;
1394
1400
}
1395
1401
1396
- private createExternalProject ( projectFileName : string , files : protocol . ExternalFile [ ] , options : protocol . ExternalProjectCompilerOptions , typeAcquisition : TypeAcquisition ) {
1402
+ private createExternalProject ( projectFileName : string , files : protocol . ExternalFile [ ] , options : protocol . ExternalProjectCompilerOptions , typeAcquisition : TypeAcquisition , excludedFiles : NormalizedPath [ ] ) {
1397
1403
const compilerOptions = convertCompilerOptions ( options ) ;
1398
1404
const project = new ExternalProject (
1399
1405
projectFileName ,
@@ -1402,6 +1408,7 @@ namespace ts.server {
1402
1408
compilerOptions ,
1403
1409
/*languageServiceEnabled*/ ! this . exceededTotalSizeLimitForNonTsFiles ( projectFileName , compilerOptions , files , externalFilePropertyReader ) ,
1404
1410
options . compileOnSave === undefined ? true : options . compileOnSave ) ;
1411
+ project . excludedFiles = excludedFiles ;
1405
1412
1406
1413
this . addFilesToNonInferredProjectAndUpdateGraph ( project , files , externalFilePropertyReader , typeAcquisition ) ;
1407
1414
this . externalProjects . push ( project ) ;
@@ -2204,7 +2211,22 @@ namespace ts.server {
2204
2211
excludedFiles . push ( normalizedNames [ i ] ) ;
2205
2212
}
2206
2213
else {
2207
- filesToKeep . push ( proj . rootFiles [ i ] ) ;
2214
+ let exclude = false ;
2215
+ if ( typeAcquisition && ( typeAcquisition . enable || typeAcquisition . enableAutoDiscovery ) ) {
2216
+ const baseName = getBaseFileName ( normalizedNames [ i ] . toLowerCase ( ) ) ;
2217
+ if ( fileExtensionIs ( baseName , "js" ) ) {
2218
+ const inferredTypingName = removeFileExtension ( baseName ) ;
2219
+ const cleanedTypingName = removeMinAndVersionNumbers ( inferredTypingName ) ;
2220
+ if ( this . legacySafelist [ cleanedTypingName ] ) {
2221
+ this . logger . info ( `Excluded '${ normalizedNames [ i ] } '` ) ;
2222
+ excludedFiles . push ( normalizedNames [ i ] ) ;
2223
+ exclude = true ;
2224
+ }
2225
+ }
2226
+ }
2227
+ if ( ! exclude ) {
2228
+ filesToKeep . push ( proj . rootFiles [ i ] ) ;
2229
+ }
2208
2230
}
2209
2231
}
2210
2232
proj . rootFiles = filesToKeep ;
@@ -2312,8 +2334,7 @@ namespace ts.server {
2312
2334
else {
2313
2335
// no config files - remove the item from the collection
2314
2336
this . externalProjectToConfiguredProjectMap . delete ( proj . projectFileName ) ;
2315
- const newProj = this . createExternalProject ( proj . projectFileName , rootFiles , proj . options , proj . typeAcquisition ) ;
2316
- newProj . excludedFiles = excludedFiles ;
2337
+ this . createExternalProject ( proj . projectFileName , rootFiles , proj . options , proj . typeAcquisition , excludedFiles ) ;
2317
2338
}
2318
2339
if ( ! suppressRefreshOfInferredProjects ) {
2319
2340
this . ensureProjectStructuresUptoDate ( /*refreshInferredProjects*/ true ) ;
0 commit comments