19
19
*/
20
20
21
21
const { TypeScriptVersion } = require ( '@definitelytyped/typescript-versions' ) ;
22
- const {
23
- cleanTypeScriptInstalls,
24
- installAllTypeScriptVersions,
25
- typeScriptPath
26
- } = require ( '@definitelytyped/utils' ) ;
22
+ const { typeScriptPath, install } = require ( '@definitelytyped/utils' ) ;
27
23
const { runTsCompile } = require ( './pre-publish' ) ;
28
24
const globby = require ( 'globby' ) ;
29
25
const semver = require ( 'semver' ) ;
30
26
31
27
const MIN_VERSION = '3.5.0' ;
32
28
33
29
async function installTs ( ) {
34
- // await cleanTypeScriptInstalls();
35
- await installAllTypeScriptVersions ( ) ;
30
+ const tsVersions = getTypeScriptVersions ( ) ;
31
+ for ( const version of tsVersions ) {
32
+ await install ( version ) ;
33
+ }
36
34
}
37
35
38
36
async function runTests ( ) {
@@ -52,11 +50,8 @@ async function runTests() {
52
50
} ;
53
51
const testsList = await globby ( __dirname + '/../test/types/*.ts' ) ;
54
52
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 ) {
60
55
console . log ( `Testing ts version ${ version } ` ) ;
61
56
const ts = require ( typeScriptPath ( version ) ) ;
62
57
await runTsCompile ( ts , compilerOptions , testsList ) ;
@@ -65,11 +60,17 @@ async function runTests() {
65
60
}
66
61
}
67
62
63
+ function getTypeScriptVersions ( ) {
64
+ return TypeScriptVersion . unsupported
65
+ . concat ( TypeScriptVersion . shipped )
66
+ . filter ( version => semver . gte ( version + '.0' , MIN_VERSION ) ) ;
67
+ }
68
+
68
69
async function main ( ) {
69
70
await installTs ( ) ;
70
71
await runTests ( ) ;
71
72
}
72
73
73
74
module . exports = main ;
74
75
75
- main ( ) ;
76
+ main ( ) ;
0 commit comments