@@ -19,6 +19,8 @@ namespace ts.server.typingsInstaller {
1919 writeLine : noop
2020 } ;
2121
22+ const timestampsFile = "timestamps.json" ;
23+
2224 function typingToFileName ( cachePath : string , packageName : string , installTypingHost : InstallTypingHost , log : Log ) : string {
2325 try {
2426 const result = resolveModuleName ( packageName , combinePaths ( cachePath , "index.d.ts" ) , { moduleResolution : ModuleResolutionKind . NodeJs } , installTypingHost ) ;
@@ -223,7 +225,7 @@ namespace ts.server.typingsInstaller {
223225 }
224226 return ;
225227 }
226- const timestampJson = combinePaths ( cacheLocation , "timestamps.json" ) ;
228+ const timestampJson = combinePaths ( cacheLocation , timestampsFile ) ;
227229 this . typeDeclarationTimestamps = loadTypeDeclarationTimestampFile ( timestampJson , this . installTypingHost , this . log ) ;
228230 const packageJson = combinePaths ( cacheLocation , "package.json" ) ;
229231 if ( this . log . isEnabled ( ) ) {
@@ -264,6 +266,9 @@ namespace ts.server.typingsInstaller {
264266 // defaults to old behavior of never updating if we ever use a host without getModifiedTime in the future
265267 const timestamp = this . installTypingHost . getModifiedTime === undefined ? Date . now ( ) : this . installTypingHost . getModifiedTime ( typingFile ) . getTime ( ) ;
266268 this . typeDeclarationTimestamps [ key ] = timestamp ;
269+ if ( this . log . isEnabled ( ) ) {
270+ this . log . writeLine ( `Adding entry into timestamp cache: '${ key } ' => '${ timestamp } '` ) ;
271+ }
267272 }
268273 // timestamp guaranteed to not be undefined by above check
269274 const newTyping : JsTyping . CachedTyping = { typingLocation : typingFile , timestamp : getProperty ( this . typeDeclarationTimestamps , key ) } ;
@@ -360,6 +365,7 @@ namespace ts.server.typingsInstaller {
360365 this . log . writeLine ( `Installed typings ${ JSON . stringify ( scopedTypings ) } ` ) ;
361366 }
362367 const installedTypingFiles : string [ ] = [ ] ;
368+ const typesPackageName = ( packageName : string ) => `@types/${ packageName } ` ;
363369 for ( const packageName of filteredTypings ) {
364370 const typingFile = typingToFileName ( cachePath , packageName , this . installTypingHost , this . log ) ;
365371 if ( ! typingFile ) {
@@ -370,15 +376,16 @@ namespace ts.server.typingsInstaller {
370376 const newTimestamp = Date . now ( ) ;
371377 const newTyping : JsTyping . CachedTyping = { typingLocation : typingFile , timestamp : newTimestamp } ;
372378 this . packageNameToTypingLocation . set ( packageName , newTyping ) ;
373- this . typeDeclarationTimestamps [ packageName ] = newTimestamp ;
379+ this . typeDeclarationTimestamps [ typesPackageName ( packageName ) ] = newTimestamp ;
374380 installedTypingFiles . push ( typingFile ) ;
375381 }
376382 if ( this . log . isEnabled ( ) ) {
377383 this . log . writeLine ( `Installed typing files ${ JSON . stringify ( installedTypingFiles ) } ` ) ;
378384 }
379385
380386 const newFileContents : TypeDeclarationTimestampFile = { entries : this . typeDeclarationTimestamps } ;
381- writeTypeDeclarationTimestampFile ( cachePath , newFileContents , this . installTypingHost , this . log ) ; // WRONG PATH
387+ const timestampJson = combinePaths ( cachePath , timestampsFile ) ;
388+ writeTypeDeclarationTimestampFile ( timestampJson , newFileContents , this . installTypingHost , this . log ) ;
382389
383390 this . sendResponse ( this . createSetTypings ( req , currentlyCachedTypings . concat ( installedTypingFiles ) ) ) ;
384391 }
0 commit comments