@@ -19,9 +19,17 @@ namespace ts.server.typingsInstaller {
19
19
writeLine : ( ) => { }
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 {
@@ -189,8 +197,9 @@ namespace ts.server.typingsInstaller {
189
197
if ( ! packageName ) {
190
198
continue ;
191
199
}
192
- const typingFile = typingToFileName ( cacheLocation , packageName , this . installTypingHost ) ;
200
+ const typingFile = typingToFileName ( cacheLocation , packageName , this . installTypingHost , this . log ) ;
193
201
if ( ! typingFile ) {
202
+ this . missingTypingsSet [ packageName ] = true ;
194
203
continue ;
195
204
}
196
205
const existingTypingFile = this . packageNameToTypingLocation [ packageName ] ;
@@ -315,16 +324,13 @@ namespace ts.server.typingsInstaller {
315
324
316
325
// TODO: watch project directory
317
326
if ( this . log . isEnabled ( ) ) {
318
- this . log . writeLine ( `Requested to install typings ${ JSON . stringify ( scopedTypings ) } , installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
327
+ this . log . writeLine ( `Installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
319
328
}
320
329
const installedTypingFiles : string [ ] = [ ] ;
321
- for ( const t of scopedTypings ) {
322
- const packageName = getBaseFileName ( t ) ;
323
- if ( ! packageName ) {
324
- continue ;
325
- }
326
- const typingFile = typingToFileName ( cachePath , packageName , this . installTypingHost ) ;
330
+ for ( const packageName of filteredTypings ) {
331
+ const typingFile = typingToFileName ( cachePath , packageName , this . installTypingHost , this . log ) ;
327
332
if ( ! typingFile ) {
333
+ this . missingTypingsSet [ packageName ] = true ;
328
334
continue ;
329
335
}
330
336
if ( ! this . packageNameToTypingLocation [ packageName ] ) {
0 commit comments