@@ -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
/**
@@ -380,6 +380,7 @@ namespace ts.server {
380
380
381
381
private readonly hostConfiguration : HostConfiguration ;
382
382
private safelist : SafeList = defaultTypeSafeList ;
383
+ private legacySafelist : { [ key : string ] : string } = { } ;
383
384
384
385
private changedFiles : ScriptInfo [ ] ;
385
386
private pendingProjectUpdates = createMap < Project > ( ) ;
@@ -432,9 +433,12 @@ namespace ts.server {
432
433
this . toCanonicalFileName = createGetCanonicalFileName ( this . host . useCaseSensitiveFileNames ) ;
433
434
this . throttledOperations = new ThrottledOperations ( this . host , this . logger ) ;
434
435
435
- if ( opts . typesMapLocation ) {
436
+ if ( this . typesMapLocation ) {
436
437
this . loadTypesMap ( ) ;
437
438
}
439
+ else {
440
+ this . logger . info ( "No types map provided; using the default" ) ;
441
+ }
438
442
439
443
this . typingsInstaller . attach ( this ) ;
440
444
@@ -524,10 +528,12 @@ namespace ts.server {
524
528
}
525
529
// raw is now fixed and ready
526
530
this . safelist = raw . typesMap ;
531
+ this . legacySafelist = raw . simpleMap ;
527
532
}
528
533
catch ( e ) {
529
534
this . logger . info ( `Error loading types map: ${ e } ` ) ;
530
535
this . safelist = defaultTypeSafeList ;
536
+ this . legacySafelist = { } ;
531
537
}
532
538
}
533
539
@@ -1418,7 +1424,7 @@ namespace ts.server {
1418
1424
}
1419
1425
}
1420
1426
1421
- private createExternalProject ( projectFileName : string , files : protocol . ExternalFile [ ] , options : protocol . ExternalProjectCompilerOptions , typeAcquisition : TypeAcquisition ) {
1427
+ private createExternalProject ( projectFileName : string , files : protocol . ExternalFile [ ] , options : protocol . ExternalProjectCompilerOptions , typeAcquisition : TypeAcquisition , excludedFiles : NormalizedPath [ ] ) {
1422
1428
const compilerOptions = convertCompilerOptions ( options ) ;
1423
1429
const project = new ExternalProject (
1424
1430
projectFileName ,
@@ -1427,6 +1433,7 @@ namespace ts.server {
1427
1433
compilerOptions ,
1428
1434
/*languageServiceEnabled*/ ! this . exceededTotalSizeLimitForNonTsFiles ( projectFileName , compilerOptions , files , externalFilePropertyReader ) ,
1429
1435
options . compileOnSave === undefined ? true : options . compileOnSave ) ;
1436
+ project . excludedFiles = excludedFiles ;
1430
1437
1431
1438
this . addFilesToNonInferredProjectAndUpdateGraph ( project , files , externalFilePropertyReader , typeAcquisition ) ;
1432
1439
this . externalProjects . push ( project ) ;
@@ -2197,7 +2204,7 @@ namespace ts.server {
2197
2204
const rule = this . safelist [ name ] ;
2198
2205
for ( const root of normalizedNames ) {
2199
2206
if ( rule . match . test ( root ) ) {
2200
- this . logger . info ( `Excluding files based on rule ${ name } ` ) ;
2207
+ this . logger . info ( `Excluding files based on rule ${ name } matching file ' ${ root } ' ` ) ;
2201
2208
2202
2209
// If the file matches, collect its types packages and exclude rules
2203
2210
if ( rule . types ) {
@@ -2256,7 +2263,22 @@ namespace ts.server {
2256
2263
excludedFiles . push ( normalizedNames [ i ] ) ;
2257
2264
}
2258
2265
else {
2259
- filesToKeep . push ( proj . rootFiles [ i ] ) ;
2266
+ let exclude = false ;
2267
+ if ( typeAcquisition && ( typeAcquisition . enable || typeAcquisition . enableAutoDiscovery ) ) {
2268
+ const baseName = getBaseFileName ( normalizedNames [ i ] . toLowerCase ( ) ) ;
2269
+ if ( fileExtensionIs ( baseName , "js" ) ) {
2270
+ const inferredTypingName = removeFileExtension ( baseName ) ;
2271
+ const cleanedTypingName = removeMinAndVersionNumbers ( inferredTypingName ) ;
2272
+ if ( this . legacySafelist [ cleanedTypingName ] ) {
2273
+ this . logger . info ( `Excluded '${ normalizedNames [ i ] } ' because it matched ${ cleanedTypingName } from the legacy safelist` ) ;
2274
+ excludedFiles . push ( normalizedNames [ i ] ) ;
2275
+ exclude = true ;
2276
+ }
2277
+ }
2278
+ }
2279
+ if ( ! exclude ) {
2280
+ filesToKeep . push ( proj . rootFiles [ i ] ) ;
2281
+ }
2260
2282
}
2261
2283
}
2262
2284
proj . rootFiles = filesToKeep ;
@@ -2364,8 +2386,7 @@ namespace ts.server {
2364
2386
else {
2365
2387
// no config files - remove the item from the collection
2366
2388
this . externalProjectToConfiguredProjectMap . delete ( proj . projectFileName ) ;
2367
- const newProj = this . createExternalProject ( proj . projectFileName , rootFiles , proj . options , proj . typeAcquisition ) ;
2368
- newProj . excludedFiles = excludedFiles ;
2389
+ this . createExternalProject ( proj . projectFileName , rootFiles , proj . options , proj . typeAcquisition , excludedFiles ) ;
2369
2390
}
2370
2391
if ( ! suppressRefreshOfInferredProjects ) {
2371
2392
this . ensureProjectStructuresUptoDate ( /*refreshInferredProjects*/ true ) ;
0 commit comments