@@ -1300,7 +1300,7 @@ namespace ts.projectSystem {
1300
1300
content : ""
1301
1301
} ;
1302
1302
const host = createServerHost ( [ f , node ] ) ;
1303
- const cache = createMapFromTemplate < JsTyping . CachedTyping > ( { node : { typingLocation : node . path , version : new Semver ( 1 , 3 , 0 , /*isPrerelease*/ false ) } } ) ;
1303
+ const cache = createMapFromTemplate < JsTyping . CachedTyping > ( { node : { typingLocation : node . path , version : Semver . parse ( "1.3.0" ) } } ) ;
1304
1304
const registry = createTypesRegistry ( "node" ) ;
1305
1305
const logger = trackingLogger ( ) ;
1306
1306
const result = JsTyping . discoverTypings ( host , logger . log , [ f . path ] , getDirectoryPath ( < Path > f . path ) , emptySafeList , cache , { enable : true } , [ "fs" , "bar" ] , registry ) ;
@@ -1358,8 +1358,8 @@ namespace ts.projectSystem {
1358
1358
} ;
1359
1359
const host = createServerHost ( [ app ] ) ;
1360
1360
const cache = createMapFromTemplate < JsTyping . CachedTyping > ( {
1361
- node : { typingLocation : node . path , version : new Semver ( 1 , 3 , 0 , /*isPrerelease*/ false ) } ,
1362
- commander : { typingLocation : commander . path , version : new Semver ( 1 , 0 , 0 , /*isPrerelease*/ false ) }
1361
+ node : { typingLocation : node . path , version : Semver . parse ( "1.3.0" ) } ,
1362
+ commander : { typingLocation : commander . path , version : Semver . parse ( "1.0.0" ) }
1363
1363
} ) ;
1364
1364
const registry = createTypesRegistry ( "node" , "commander" ) ;
1365
1365
const logger = trackingLogger ( ) ;
@@ -1371,6 +1371,64 @@ namespace ts.projectSystem {
1371
1371
assert . deepEqual ( result . cachedTypingPaths , [ node . path ] ) ;
1372
1372
assert . deepEqual ( result . newTypingNames , [ "commander" ] ) ;
1373
1373
} ) ;
1374
+
1375
+ it ( "should install expired typings with prerelease version of tsserver" , ( ) => {
1376
+ const app = {
1377
+ path : "/a/app.js" ,
1378
+ content : ""
1379
+ } ;
1380
+ const cachePath = "/a/cache/" ;
1381
+ const node = {
1382
+ path : cachePath + "node_modules/@types/node/index.d.ts" ,
1383
+ content : "export let y: number"
1384
+ } ;
1385
+ const host = createServerHost ( [ app ] ) ;
1386
+ const cache = createMapFromTemplate < JsTyping . CachedTyping > ( {
1387
+ node : { typingLocation : node . path , version : Semver . parse ( "1.0.0" ) }
1388
+ } ) ;
1389
+ const registry = createTypesRegistry ( "node" ) ;
1390
+ registry . delete ( `ts${ ts . versionMajorMinor } ` ) ;
1391
+ const logger = trackingLogger ( ) ;
1392
+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , [ "http" ] , registry ) ;
1393
+ assert . deepEqual ( logger . finish ( ) , [
1394
+ 'Inferred typings from unresolved imports: ["node"]' ,
1395
+ 'Result: {"cachedTypingPaths":[],"newTypingNames":["node"],"filesToWatch":["/a/bower_components","/a/node_modules"]}' ,
1396
+ ] ) ;
1397
+ assert . deepEqual ( result . cachedTypingPaths , [ ] ) ;
1398
+ assert . deepEqual ( result . newTypingNames , [ "node" ] ) ;
1399
+ } ) ;
1400
+
1401
+
1402
+ it ( "prerelease typings are properly handled" , ( ) => {
1403
+ const app = {
1404
+ path : "/a/app.js" ,
1405
+ content : ""
1406
+ } ;
1407
+ const cachePath = "/a/cache/" ;
1408
+ const commander = {
1409
+ path : cachePath + "node_modules/@types/commander/index.d.ts" ,
1410
+ content : "export let x: number"
1411
+ } ;
1412
+ const node = {
1413
+ path : cachePath + "node_modules/@types/node/index.d.ts" ,
1414
+ content : "export let y: number"
1415
+ } ;
1416
+ const host = createServerHost ( [ app ] ) ;
1417
+ const cache = createMapFromTemplate < JsTyping . CachedTyping > ( {
1418
+ node : { typingLocation : node . path , version : Semver . parse ( "1.3.0-next.0" ) } ,
1419
+ commander : { typingLocation : commander . path , version : Semver . parse ( "1.3.0-next.0" ) }
1420
+ } ) ;
1421
+ const registry = createTypesRegistry ( "node" , "commander" ) ;
1422
+ registry . get ( "node" ) [ `ts${ ts . versionMajorMinor } ` ] = "1.3.0-next.1" ;
1423
+ const logger = trackingLogger ( ) ;
1424
+ const result = JsTyping . discoverTypings ( host , logger . log , [ app . path ] , getDirectoryPath ( < Path > app . path ) , emptySafeList , cache , { enable : true } , [ "http" , "commander" ] , registry ) ;
1425
+ assert . deepEqual ( logger . finish ( ) , [
1426
+ 'Inferred typings from unresolved imports: ["node","commander"]' ,
1427
+ 'Result: {"cachedTypingPaths":[],"newTypingNames":["node","commander"],"filesToWatch":["/a/bower_components","/a/node_modules"]}' ,
1428
+ ] ) ;
1429
+ assert . deepEqual ( result . cachedTypingPaths , [ ] ) ;
1430
+ assert . deepEqual ( result . newTypingNames , [ "node" , "commander" ] ) ;
1431
+ } ) ;
1374
1432
} ) ;
1375
1433
1376
1434
describe ( "telemetry events" , ( ) => {
0 commit comments