@@ -110,7 +110,7 @@ namespace ts.server {
110110
111111 export interface TypesMapFile {
112112 typesMap : SafeList ;
113- simpleMap : string [ ] ;
113+ simpleMap : { [ libName : string ] : string } ;
114114 }
115115
116116 /**
@@ -380,6 +380,7 @@ namespace ts.server {
380380
381381 private readonly hostConfiguration : HostConfiguration ;
382382 private safelist : SafeList = defaultTypeSafeList ;
383+ private legacySafelist : { [ key : string ] : string } = { } ;
383384
384385 private changedFiles : ScriptInfo [ ] ;
385386 private pendingProjectUpdates = createMap < Project > ( ) ;
@@ -432,9 +433,12 @@ namespace ts.server {
432433 this . toCanonicalFileName = createGetCanonicalFileName ( this . host . useCaseSensitiveFileNames ) ;
433434 this . throttledOperations = new ThrottledOperations ( this . host , this . logger ) ;
434435
435- if ( opts . typesMapLocation ) {
436+ if ( this . typesMapLocation ) {
436437 this . loadTypesMap ( ) ;
437438 }
439+ else {
440+ this . logger . info ( "No types map provided; using the default" ) ;
441+ }
438442
439443 this . typingsInstaller . attach ( this ) ;
440444
@@ -524,10 +528,12 @@ namespace ts.server {
524528 }
525529 // raw is now fixed and ready
526530 this . safelist = raw . typesMap ;
531+ this . legacySafelist = raw . simpleMap ;
527532 }
528533 catch ( e ) {
529534 this . logger . info ( `Error loading types map: ${ e } ` ) ;
530535 this . safelist = defaultTypeSafeList ;
536+ this . legacySafelist = { } ;
531537 }
532538 }
533539
@@ -1418,7 +1424,7 @@ namespace ts.server {
14181424 }
14191425 }
14201426
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 [ ] ) {
14221428 const compilerOptions = convertCompilerOptions ( options ) ;
14231429 const project = new ExternalProject (
14241430 projectFileName ,
@@ -1427,6 +1433,7 @@ namespace ts.server {
14271433 compilerOptions ,
14281434 /*languageServiceEnabled*/ ! this . exceededTotalSizeLimitForNonTsFiles ( projectFileName , compilerOptions , files , externalFilePropertyReader ) ,
14291435 options . compileOnSave === undefined ? true : options . compileOnSave ) ;
1436+ project . excludedFiles = excludedFiles ;
14301437
14311438 this . addFilesToNonInferredProjectAndUpdateGraph ( project , files , externalFilePropertyReader , typeAcquisition ) ;
14321439 this . externalProjects . push ( project ) ;
@@ -2197,7 +2204,7 @@ namespace ts.server {
21972204 const rule = this . safelist [ name ] ;
21982205 for ( const root of normalizedNames ) {
21992206 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 } ' ` ) ;
22012208
22022209 // If the file matches, collect its types packages and exclude rules
22032210 if ( rule . types ) {
@@ -2256,7 +2263,22 @@ namespace ts.server {
22562263 excludedFiles . push ( normalizedNames [ i ] ) ;
22572264 }
22582265 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+ }
22602282 }
22612283 }
22622284 proj . rootFiles = filesToKeep ;
@@ -2364,8 +2386,7 @@ namespace ts.server {
23642386 else {
23652387 // no config files - remove the item from the collection
23662388 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 ) ;
23692390 }
23702391 if ( ! suppressRefreshOfInferredProjects ) {
23712392 this . ensureProjectStructuresUptoDate ( /*refreshInferredProjects*/ true ) ;
0 commit comments