1919*/
2020
2121const { TypeScriptVersion } = require ( '@definitelytyped/typescript-versions' ) ;
22- const {
23- cleanTypeScriptInstalls,
24- installAllTypeScriptVersions,
25- typeScriptPath
26- } = require ( '@definitelytyped/utils' ) ;
22+ const { typeScriptPath, install } = require ( '@definitelytyped/utils' ) ;
2723const { runTsCompile } = require ( './pre-publish' ) ;
2824const globby = require ( 'globby' ) ;
2925const semver = require ( 'semver' ) ;
3026
3127const MIN_VERSION = '3.5.0' ;
3228
3329async function installTs ( ) {
34- // await cleanTypeScriptInstalls();
35- await installAllTypeScriptVersions ( ) ;
30+ const tsVersions = getTypeScriptVersions ( ) ;
31+ for ( const version of tsVersions ) {
32+ await install ( version ) ;
33+ }
3634}
3735
3836async function runTests ( ) {
@@ -52,11 +50,8 @@ async function runTests() {
5250 } ;
5351 const testsList = await globby ( __dirname + '/../test/types/*.ts' ) ;
5452
55- for ( let version of TypeScriptVersion . shipped ) {
56- if ( semver . lt ( version + '.0' , MIN_VERSION ) ) {
57- continue ;
58- }
59-
53+ const tsVersions = getTypeScriptVersions ( ) ;
54+ for ( const version of tsVersions ) {
6055 console . log ( `Testing ts version ${ version } ` ) ;
6156 const ts = require ( typeScriptPath ( version ) ) ;
6257 await runTsCompile ( ts , compilerOptions , testsList ) ;
@@ -65,11 +60,17 @@ async function runTests() {
6560 }
6661}
6762
63+ function getTypeScriptVersions ( ) {
64+ return TypeScriptVersion . unsupported
65+ . concat ( TypeScriptVersion . shipped )
66+ . filter ( version => semver . gte ( version + '.0' , MIN_VERSION ) ) ;
67+ }
68+
6869async function main ( ) {
6970 await installTs ( ) ;
7071 await runTests ( ) ;
7172}
7273
7374module . exports = main ;
7475
75- main ( ) ;
76+ main ( ) ;
0 commit comments