@@ -19,9 +19,17 @@ namespace ts.server.typingsInstaller {
1919 writeLine : noop
2020 } ;
2121
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+ }
2533 }
2634
2735 export enum PackageNameValidationResult {
@@ -192,8 +200,9 @@ namespace ts.server.typingsInstaller {
192200 if ( ! packageName ) {
193201 continue ;
194202 }
195- const typingFile = typingToFileName ( cacheLocation , packageName , this . installTypingHost ) ;
203+ const typingFile = typingToFileName ( cacheLocation , packageName , this . installTypingHost , this . log ) ;
196204 if ( ! typingFile ) {
205+ this . missingTypingsSet [ packageName ] = true ;
197206 continue ;
198207 }
199208 const existingTypingFile = this . packageNameToTypingLocation [ packageName ] ;
@@ -224,7 +233,7 @@ namespace ts.server.typingsInstaller {
224233 }
225234 const result : string [ ] = [ ] ;
226235 for ( const typing of typingsToInstall ) {
227- if ( this . missingTypingsSet [ typing ] ) {
236+ if ( this . missingTypingsSet [ typing ] || this . packageNameToTypingLocation [ typing ] ) {
228237 continue ;
229238 }
230239 const validationResult = validatePackageName ( typing ) ;
@@ -305,7 +314,8 @@ namespace ts.server.typingsInstaller {
305314 this . sendResponse ( < TypingsInstallEvent > {
306315 kind : EventInstall ,
307316 packagesToInstall : scopedTypings ,
308- installSuccess : ok
317+ installSuccess : ok ,
318+ typingsInstallerVersion : ts . version // qualified explicitly to prevent occasional shadowing
309319 } ) ;
310320 }
311321
@@ -321,16 +331,13 @@ namespace ts.server.typingsInstaller {
321331
322332 // TODO: watch project directory
323333 if ( this . log . isEnabled ( ) ) {
324- this . log . writeLine ( `Requested to install typings ${ JSON . stringify ( scopedTypings ) } , installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
334+ this . log . writeLine ( `Installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
325335 }
326336 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 ) ;
337+ for ( const packageName of filteredTypings ) {
338+ const typingFile = typingToFileName ( cachePath , packageName , this . installTypingHost , this . log ) ;
333339 if ( ! typingFile ) {
340+ this . missingTypingsSet [ packageName ] = true ;
334341 continue ;
335342 }
336343 if ( ! this . packageNameToTypingLocation [ packageName ] ) {
0 commit comments