@@ -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 /**
@@ -374,6 +374,7 @@ namespace ts.server {
374374
375375 private readonly hostConfiguration : HostConfiguration ;
376376 private safelist : SafeList = defaultTypeSafeList ;
377+ private legacySafelist : { [ key : string ] : string } = { } ;
377378
378379 private changedFiles : ScriptInfo [ ] ;
379380 private pendingProjectUpdates = createMap < Project > ( ) ;
@@ -426,9 +427,12 @@ namespace ts.server {
426427 this . toCanonicalFileName = createGetCanonicalFileName ( this . host . useCaseSensitiveFileNames ) ;
427428 this . throttledOperations = new ThrottledOperations ( this . host , this . logger ) ;
428429
429- if ( opts . typesMapLocation ) {
430+ if ( this . typesMapLocation ) {
430431 this . loadTypesMap ( ) ;
431432 }
433+ else {
434+ this . logger . info ( "No types map provided; using the default" ) ;
435+ }
432436
433437 this . typingsInstaller . attach ( this ) ;
434438
@@ -518,10 +522,12 @@ namespace ts.server {
518522 }
519523 // raw is now fixed and ready
520524 this . safelist = raw . typesMap ;
525+ this . legacySafelist = raw . simpleMap ;
521526 }
522527 catch ( e ) {
523528 this . logger . info ( `Error loading types map: ${ e } ` ) ;
524529 this . safelist = defaultTypeSafeList ;
530+ this . legacySafelist = { } ;
525531 }
526532 }
527533
@@ -1393,7 +1399,7 @@ namespace ts.server {
13931399 return false ;
13941400 }
13951401
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 [ ] ) {
13971403 const compilerOptions = convertCompilerOptions ( options ) ;
13981404 const project = new ExternalProject (
13991405 projectFileName ,
@@ -1402,6 +1408,7 @@ namespace ts.server {
14021408 compilerOptions ,
14031409 /*languageServiceEnabled*/ ! this . exceededTotalSizeLimitForNonTsFiles ( projectFileName , compilerOptions , files , externalFilePropertyReader ) ,
14041410 options . compileOnSave === undefined ? true : options . compileOnSave ) ;
1411+ project . excludedFiles = excludedFiles ;
14051412
14061413 this . addFilesToNonInferredProjectAndUpdateGraph ( project , files , externalFilePropertyReader , typeAcquisition ) ;
14071414 this . externalProjects . push ( project ) ;
@@ -2204,7 +2211,22 @@ namespace ts.server {
22042211 excludedFiles . push ( normalizedNames [ i ] ) ;
22052212 }
22062213 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+ }
22082230 }
22092231 }
22102232 proj . rootFiles = filesToKeep ;
@@ -2312,8 +2334,7 @@ namespace ts.server {
23122334 else {
23132335 // no config files - remove the item from the collection
23142336 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 ) ;
23172338 }
23182339 if ( ! suppressRefreshOfInferredProjects ) {
23192340 this . ensureProjectStructuresUptoDate ( /*refreshInferredProjects*/ true ) ;
0 commit comments