@@ -205,35 +205,29 @@ namespace ts.server.typingsInstaller {
205
205
this . knownCachesSet . set ( cacheLocation , true ) ;
206
206
}
207
207
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 ;
216
213
}
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 ;
227
217
}
228
- else {
218
+ const validationResult = JsTyping . validatePackageName ( typing ) ;
219
+ if ( validationResult !== JsTyping . PackageNameValidationResult . Ok ) {
229
220
// add typing name to missing set so we won't process it again
230
221
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 ;
234
224
}
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
+ } ) ;
237
231
}
238
232
239
233
protected ensurePackageDirectoryExists ( directory : string ) {
0 commit comments