@@ -205,35 +205,29 @@ namespace ts.server.typingsInstaller {
205205 this . knownCachesSet . set ( cacheLocation , true ) ;
206206 }
207207
208- private filterTypings ( typingsToInstall : string [ ] ) {
209- if ( typingsToInstall . length === 0 ) {
210- return typingsToInstall ;
211- }
212- const result : string [ ] = [ ] ;
213- for ( const typing of typingsToInstall ) {
214- if ( this . missingTypingsSet . get ( typing ) || this . packageNameToTypingLocation . get ( typing ) ) {
215- continue ;
208+ private filterTypings ( typingsToInstall : ReadonlyArray < string > ) : ReadonlyArray < string > {
209+ return typingsToInstall . filter ( typing => {
210+ if ( this . missingTypingsSet . get ( typing ) ) {
211+ if ( this . log . isEnabled ( ) ) this . log . writeLine ( `'${ typing } ' is in missingTypingsSet - skipping...` ) ;
212+ return false ;
216213 }
217- const validationResult = JsTyping . validatePackageName ( typing ) ;
218- if ( validationResult === JsTyping . PackageNameValidationResult . Ok ) {
219- if ( this . typesRegistry . has ( typing ) ) {
220- result . push ( typing ) ;
221- }
222- else {
223- if ( this . log . isEnabled ( ) ) {
224- this . log . writeLine ( `Entry for package '${ typing } ' does not exist in local types registry - skipping...` ) ;
225- }
226- }
214+ if ( this . packageNameToTypingLocation . get ( typing ) ) {
215+ if ( this . log . isEnabled ( ) ) this . log . writeLine ( `'${ typing } ' already has a typing - skipping...` ) ;
216+ return false ;
227217 }
228- else {
218+ const validationResult = JsTyping . validatePackageName ( typing ) ;
219+ if ( validationResult !== JsTyping . PackageNameValidationResult . Ok ) {
229220 // add typing name to missing set so we won't process it again
230221 this . missingTypingsSet . set ( typing , true ) ;
231- if ( this . log . isEnabled ( ) ) {
232- this . log . writeLine ( JsTyping . renderPackageNameValidationFailure ( validationResult , typing ) ) ;
233- }
222+ if ( this . log . isEnabled ( ) ) this . log . writeLine ( JsTyping . renderPackageNameValidationFailure ( validationResult , typing ) ) ;
223+ return false ;
234224 }
235- }
236- return result ;
225+ if ( ! this . typesRegistry . has ( typing ) ) {
226+ if ( this . log . isEnabled ( ) ) this . log . writeLine ( `Entry for package '${ typing } ' does not exist in local types registry - skipping...` ) ;
227+ return false ;
228+ }
229+ return true ;
230+ } ) ;
237231 }
238232
239233 protected ensurePackageDirectoryExists ( directory : string ) {
0 commit comments