@@ -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 ] ;
@@ -224,7 +233,7 @@ namespace ts.server.typingsInstaller {
224
233
}
225
234
const result : string [ ] = [ ] ;
226
235
for ( const typing of typingsToInstall ) {
227
- if ( this . missingTypingsSet [ typing ] ) {
236
+ if ( this . missingTypingsSet [ typing ] || this . packageNameToTypingLocation [ typing ] ) {
228
237
continue ;
229
238
}
230
239
const validationResult = validatePackageName ( typing ) ;
@@ -305,7 +314,8 @@ namespace ts.server.typingsInstaller {
305
314
this . sendResponse ( < TypingsInstallEvent > {
306
315
kind : EventInstall ,
307
316
packagesToInstall : scopedTypings ,
308
- installSuccess : ok
317
+ installSuccess : ok ,
318
+ typingsInstallerVersion : ts . version // qualified explicitly to prevent occasional shadowing
309
319
} ) ;
310
320
}
311
321
@@ -321,16 +331,13 @@ namespace ts.server.typingsInstaller {
321
331
322
332
// TODO: watch project directory
323
333
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 ) } ` ) ;
325
335
}
326
336
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 ) ;
333
339
if ( ! typingFile ) {
340
+ this . missingTypingsSet [ packageName ] = true ;
334
341
continue ;
335
342
}
336
343
if ( ! this . packageNameToTypingLocation [ packageName ] ) {
0 commit comments