@@ -1300,7 +1300,7 @@ namespace ts.projectSystem {
13001300 content : ""
13011301 } ;
13021302 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" ) } } ) ;
13041304 const registry = createTypesRegistry ( "node" ) ;
13051305 const logger = trackingLogger ( ) ;
13061306 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 {
13581358 } ;
13591359 const host = createServerHost ( [ app ] ) ;
13601360 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" ) }
13631363 } ) ;
13641364 const registry = createTypesRegistry ( "node" , "commander" ) ;
13651365 const logger = trackingLogger ( ) ;
@@ -1371,6 +1371,64 @@ namespace ts.projectSystem {
13711371 assert . deepEqual ( result . cachedTypingPaths , [ node . path ] ) ;
13721372 assert . deepEqual ( result . newTypingNames , [ "commander" ] ) ;
13731373 } ) ;
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+ } ) ;
13741432 } ) ;
13751433
13761434 describe ( "telemetry events" , ( ) => {
0 commit comments