@@ -19,9 +19,17 @@ namespace ts.server.typingsInstaller {
19
19
writeLine : noop
20
20
} ;
21
21
22
- function typingToFileName ( cachePath : string , packageName : string , installTypingHost : InstallTypingHost ) : string {
23
- const result = resolveModuleName ( packageName , combinePaths ( cachePath , "index.d.ts" ) , { moduleResolution : ModuleResolutionKind . NodeJs } , installTypingHost ) ;
24
- return result . resolvedModule && result . resolvedModule . resolvedFileName ;
22
+ function typingToFileName ( cachePath : string , packageName : string , installTypingHost : InstallTypingHost , log : Log ) : string {
23
+ try {
24
+ const result = resolveModuleName ( packageName , combinePaths ( cachePath , "index.d.ts" ) , { moduleResolution : ModuleResolutionKind . NodeJs } , installTypingHost ) ;
25
+ return result . resolvedModule && result . resolvedModule . resolvedFileName ;
26
+ }
27
+ catch ( e ) {
28
+ if ( log . isEnabled ( ) ) {
29
+ log . writeLine ( `Failed to resolve ${ packageName } in folder '${ cachePath } ': ${ ( < Error > e ) . message } ` ) ;
30
+ }
31
+ return undefined ;
32
+ }
25
33
}
26
34
27
35
export enum PackageNameValidationResult {
@@ -192,8 +200,9 @@ namespace ts.server.typingsInstaller {
192
200
if ( ! packageName ) {
193
201
continue ;
194
202
}
195
- const typingFile = typingToFileName ( cacheLocation , packageName , this . installTypingHost ) ;
203
+ const typingFile = typingToFileName ( cacheLocation , packageName , this . installTypingHost , this . log ) ;
196
204
if ( ! typingFile ) {
205
+ this . missingTypingsSet [ packageName ] = true ;
197
206
continue ;
198
207
}
199
208
const existingTypingFile = this . packageNameToTypingLocation [ packageName ] ;
@@ -321,16 +330,13 @@ namespace ts.server.typingsInstaller {
321
330
322
331
// TODO: watch project directory
323
332
if ( this . log . isEnabled ( ) ) {
324
- this . log . writeLine ( `Requested to install typings ${ JSON . stringify ( scopedTypings ) } , installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
333
+ this . log . writeLine ( `Installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
325
334
}
326
335
const installedTypingFiles : string [ ] = [ ] ;
327
- for ( const t of scopedTypings ) {
328
- const packageName = getBaseFileName ( t ) ;
329
- if ( ! packageName ) {
330
- continue ;
331
- }
332
- const typingFile = typingToFileName ( cachePath , packageName , this . installTypingHost ) ;
336
+ for ( const packageName of filteredTypings ) {
337
+ const typingFile = typingToFileName ( cachePath , packageName , this . installTypingHost , this . log ) ;
333
338
if ( ! typingFile ) {
339
+ this . missingTypingsSet [ packageName ] = true ;
334
340
continue ;
335
341
}
336
342
if ( ! this . packageNameToTypingLocation [ packageName ] ) {
0 commit comments