@@ -1081,16 +1081,6 @@ namespace ts.projectSystem {
1081
1081
}
1082
1082
} )
1083
1083
} ;
1084
- const date = new Date ( ) ;
1085
- date . setFullYear ( date . getFullYear ( ) - 1 ) ;
1086
- const timestamps = {
1087
- path : "/a/data/timestamps.json" ,
1088
- content : JSON . stringify ( {
1089
- entries : {
1090
- "@types/jquery" : date . getTime ( )
1091
- }
1092
- } )
1093
- } ;
1094
1084
const jquery = {
1095
1085
path : "/a/data/node_modules/@types/jquery/index.d.ts" ,
1096
1086
content : "declare const $: { x: number }"
@@ -1102,11 +1092,21 @@ namespace ts.projectSystem {
1102
1092
"types-registry" : "^0.1.317"
1103
1093
} ,
1104
1094
devDependencies : {
1105
- "@types/jquery" : "^3.2.16"
1095
+ "@types/jquery" : "^1.0.0"
1096
+ }
1097
+ } )
1098
+ } ;
1099
+ const cacheLockConfig = {
1100
+ path : "/a/data/package-lock.json" ,
1101
+ content : JSON . stringify ( {
1102
+ dependencies : {
1103
+ "@types/jquery" : {
1104
+ version : "1.0.0"
1105
+ }
1106
1106
}
1107
1107
} )
1108
1108
} ;
1109
- const host = createServerHost ( [ file1 , packageJson , jquery , timestamps , cacheConfig ] ) ;
1109
+ const host = createServerHost ( [ file1 , packageJson , jquery , cacheConfig , cacheLockConfig ] ) ;
1110
1110
const installer = new ( class extends Installer {
1111
1111
constructor ( ) {
1112
1112
super ( host , { typesRegistry : createTypesRegistry ( "jquery" ) } ) ;
@@ -1129,7 +1129,6 @@ namespace ts.projectSystem {
1129
1129
1130
1130
checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
1131
1131
checkProjectActualFiles ( p , [ file1 . path , jquery . path ] ) ;
1132
- assert ( host . readFile ( timestamps . path ) !== JSON . stringify ( { entries : { "@types/jquery" : date . getTime ( ) } } ) , "timestamps content should be updated" ) ;
1133
1132
} ) ;
1134
1133
1135
1134
it ( "non-expired cache entry (inferred project, should not install typings)" , ( ) => {
@@ -1282,7 +1281,7 @@ namespace ts.projectSystem {
1282
1281
1283
1282
const host = createServerHost ( [ app , jquery , chroma ] ) ;
1284
1283
const logger = trackingLogger ( ) ;
1285
- const result = JsTyping . discoverTypings ( host , logger . log , [ app . path , jquery . path , chroma . path ] , getDirectoryPath ( < Path > app . path ) , safeList , emptyMap , { enable : true } , emptyArray ) ;
1284
+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path , jquery . path , chroma . path ] , getDirectoryPath ( < Path > app . path ) , safeList , emptyMap , { enable : true } , emptyArray , emptyMap ) ;
1286
1285
const finish = logger . finish ( ) ;
1287
1286
assert . deepEqual ( finish , [
1288
1287
'Inferred typings from file names: ["jquery","chroma-js"]' ,
@@ -1302,7 +1301,7 @@ namespace ts.projectSystem {
1302
1301
1303
1302
for ( const name of JsTyping . nodeCoreModuleList ) {
1304
1303
const logger = trackingLogger ( ) ;
1305
- const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ name , "somename" ] ) ;
1304
+ const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ name , "somename" ] , emptyMap ) ;
1306
1305
assert . deepEqual ( logger . finish ( ) , [
1307
1306
'Inferred typings from unresolved imports: ["node","somename"]' ,
1308
1307
'Result: {"cachedTypingPaths":[],"newTypingNames":["node","somename"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1321,9 +1320,10 @@ namespace ts.projectSystem {
1321
1320
content : ""
1322
1321
} ;
1323
1322
const host = createServerHost ( [ f , node ] ) ;
1324
- const cache = createMapFromTemplate < JsTyping . CachedTyping > ( { node : { typingLocation : node . path , timestamp : Date . now ( ) , version : new Semver ( 1 , 0 , 0 , /*isPrerelease*/ false ) } } ) ;
1323
+ const cache = createMapFromTemplate < JsTyping . CachedTyping > ( { node : { typingLocation : node . path , version : new Semver ( 1 , 3 , 0 , /*isPrerelease*/ false ) } } ) ;
1324
+ const registry = createTypesRegistry ( "node" ) ;
1325
1325
const logger = trackingLogger ( ) ;
1326
- const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ "fs" , "bar" ] ) ;
1326
+ const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ "fs" , "bar" ] , registry ) ;
1327
1327
assert . deepEqual ( logger . finish ( ) , [
1328
1328
'Inferred typings from unresolved imports: ["node","bar"]' ,
1329
1329
'Result: {"cachedTypingPaths":["/a/b/node.d.ts"],"newTypingNames":["bar"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}' ,
@@ -1348,7 +1348,7 @@ namespace ts.projectSystem {
1348
1348
const host = createServerHost ( [ app , a , b ] ) ;
1349
1349
const cache = createMap < JsTyping . CachedTyping > ( ) ;
1350
1350
const logger = trackingLogger ( ) ;
1351
- const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , /*unresolvedImports*/ [ ] ) ;
1351
+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , /*unresolvedImports*/ [ ] , emptyMap ) ;
1352
1352
assert . deepEqual ( logger . finish ( ) , [
1353
1353
'Searching for typing names in /node_modules; all files: ["/node_modules/a/package.json"]' ,
1354
1354
' Found package names: ["a"]' ,
@@ -1363,9 +1363,6 @@ namespace ts.projectSystem {
1363
1363
} ) ;
1364
1364
1365
1365
it ( "should install expired typings" , ( ) => {
1366
- const date = new Date ( ) ;
1367
- date . setFullYear ( date . getFullYear ( ) - 1 ) ;
1368
-
1369
1366
const app = {
1370
1367
path : "/a/app.js" ,
1371
1368
content : ""
@@ -1381,11 +1378,12 @@ namespace ts.projectSystem {
1381
1378
} ;
1382
1379
const host = createServerHost ( [ app ] ) ;
1383
1380
const cache = createMapFromTemplate < JsTyping . CachedTyping > ( {
1384
- node : { typingLocation : node . path , timestamp : Date . now ( ) , version : new Semver ( 1 , 0 , 0 , /*isPrerelease*/ false ) } ,
1385
- commander : { typingLocation : commander . path , timestamp : date . getTime ( ) , version : new Semver ( 1 , 0 , 0 , /*isPrerelease*/ false ) }
1381
+ node : { typingLocation : node . path , version : new Semver ( 1 , 3 , 0 , /*isPrerelease*/ false ) } ,
1382
+ commander : { typingLocation : commander . path , version : new Semver ( 1 , 0 , 0 , /*isPrerelease*/ false ) }
1386
1383
} ) ;
1384
+ const registry = createTypesRegistry ( "node" , "commander" ) ;
1387
1385
const logger = trackingLogger ( ) ;
1388
- const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , [ "http" , "commander" ] ) ;
1386
+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , [ "http" , "commander" ] , registry ) ;
1389
1387
assert . deepEqual ( logger . finish ( ) , [
1390
1388
'Inferred typings from unresolved imports: ["node","commander"]' ,
1391
1389
'Result: {"cachedTypingPaths":["/a/cache/node_modules/@types/node/index.d.ts"],"newTypingNames":["commander"],"filesToWatch":["/a/bower_components","/a/node_modules"]}' ,
0 commit comments