@@ -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
/**
@@ -378,6 +378,7 @@ namespace ts.server {
378
378
379
379
private readonly hostConfiguration : HostConfiguration ;
380
380
private safelist : SafeList = defaultTypeSafeList ;
381
+ private legacySafelist : { [ key : string ] : string } = { } ;
381
382
382
383
private changedFiles : ScriptInfo [ ] ;
383
384
private pendingProjectUpdates = createMap < Project > ( ) ;
@@ -430,9 +431,12 @@ namespace ts.server {
430
431
this . toCanonicalFileName = createGetCanonicalFileName ( this . host . useCaseSensitiveFileNames ) ;
431
432
this . throttledOperations = new ThrottledOperations ( this . host , this . logger ) ;
432
433
433
- if ( opts . typesMapLocation ) {
434
+ if ( this . typesMapLocation ) {
434
435
this . loadTypesMap ( ) ;
435
436
}
437
+ else {
438
+ this . logger . info ( "No types map provided; using the default" ) ;
439
+ }
436
440
437
441
this . typingsInstaller . attach ( this ) ;
438
442
@@ -522,10 +526,12 @@ namespace ts.server {
522
526
}
523
527
// raw is now fixed and ready
524
528
this . safelist = raw . typesMap ;
529
+ this . legacySafelist = raw . simpleMap ;
525
530
}
526
531
catch ( e ) {
527
532
this . logger . info ( `Error loading types map: ${ e } ` ) ;
528
533
this . safelist = defaultTypeSafeList ;
534
+ this . legacySafelist = { } ;
529
535
}
530
536
}
531
537
@@ -1396,7 +1402,7 @@ namespace ts.server {
1396
1402
return false ;
1397
1403
}
1398
1404
1399
- private createExternalProject ( projectFileName : string , files : protocol . ExternalFile [ ] , options : protocol . ExternalProjectCompilerOptions , typeAcquisition : TypeAcquisition ) {
1405
+ private createExternalProject ( projectFileName : string , files : protocol . ExternalFile [ ] , options : protocol . ExternalProjectCompilerOptions , typeAcquisition : TypeAcquisition , excludedFiles : NormalizedPath [ ] ) {
1400
1406
const compilerOptions = convertCompilerOptions ( options ) ;
1401
1407
const project = new ExternalProject (
1402
1408
projectFileName ,
@@ -1405,6 +1411,7 @@ namespace ts.server {
1405
1411
compilerOptions ,
1406
1412
/*languageServiceEnabled*/ ! this . exceededTotalSizeLimitForNonTsFiles ( projectFileName , compilerOptions , files , externalFilePropertyReader ) ,
1407
1413
options . compileOnSave === undefined ? true : options . compileOnSave ) ;
1414
+ project . excludedFiles = excludedFiles ;
1408
1415
1409
1416
this . addFilesToNonInferredProjectAndUpdateGraph ( project , files , externalFilePropertyReader , typeAcquisition ) ;
1410
1417
this . externalProjects . push ( project ) ;
@@ -2170,7 +2177,7 @@ namespace ts.server {
2170
2177
const rule = this . safelist [ name ] ;
2171
2178
for ( const root of normalizedNames ) {
2172
2179
if ( rule . match . test ( root ) ) {
2173
- this . logger . info ( `Excluding files based on rule ${ name } ` ) ;
2180
+ this . logger . info ( `Excluding files based on rule ${ name } matching file ' ${ root } ' ` ) ;
2174
2181
2175
2182
// If the file matches, collect its types packages and exclude rules
2176
2183
if ( rule . types ) {
@@ -2229,7 +2236,22 @@ namespace ts.server {
2229
2236
excludedFiles . push ( normalizedNames [ i ] ) ;
2230
2237
}
2231
2238
else {
2232
- filesToKeep . push ( proj . rootFiles [ i ] ) ;
2239
+ let exclude = false ;
2240
+ if ( typeAcquisition && ( typeAcquisition . enable || typeAcquisition . enableAutoDiscovery ) ) {
2241
+ const baseName = getBaseFileName ( normalizedNames [ i ] . toLowerCase ( ) ) ;
2242
+ if ( fileExtensionIs ( baseName , "js" ) ) {
2243
+ const inferredTypingName = removeFileExtension ( baseName ) ;
2244
+ const cleanedTypingName = removeMinAndVersionNumbers ( inferredTypingName ) ;
2245
+ if ( this . legacySafelist [ cleanedTypingName ] ) {
2246
+ this . logger . info ( `Excluded '${ normalizedNames [ i ] } ' because it matched ${ cleanedTypingName } from the legacy safelist` ) ;
2247
+ excludedFiles . push ( normalizedNames [ i ] ) ;
2248
+ exclude = true ;
2249
+ }
2250
+ }
2251
+ }
2252
+ if ( ! exclude ) {
2253
+ filesToKeep . push ( proj . rootFiles [ i ] ) ;
2254
+ }
2233
2255
}
2234
2256
}
2235
2257
proj . rootFiles = filesToKeep ;
@@ -2337,8 +2359,7 @@ namespace ts.server {
2337
2359
else {
2338
2360
// no config files - remove the item from the collection
2339
2361
this . externalProjectToConfiguredProjectMap . delete ( proj . projectFileName ) ;
2340
- const newProj = this . createExternalProject ( proj . projectFileName , rootFiles , proj . options , proj . typeAcquisition ) ;
2341
- newProj . excludedFiles = excludedFiles ;
2362
+ this . createExternalProject ( proj . projectFileName , rootFiles , proj . options , proj . typeAcquisition , excludedFiles ) ;
2342
2363
}
2343
2364
if ( ! suppressRefreshOfInferredProjects ) {
2344
2365
this . ensureProjectStructuresUptoDate ( /*refreshInferredProjects*/ true ) ;
0 commit comments