@@ -20,16 +20,30 @@ import {assert} from "chai"
20
20
* EXCLUDE_TYPINGS_COMPAT_TESTS=true
21
21
*/
22
22
23
- type TestDef = { version : string ; minTarget : string ; requiredLibs ?: string [ ] }
23
+ type TestDef = {
24
+ tscVersion : string
25
+ nodeTypesVersion : string
26
+ minTarget : string
27
+ requiredLibs ?: string [ ]
28
+ }
24
29
25
30
const tsVersions : TestDef [ ] = [
31
+ // the oldest supported version
32
+ { tscVersion : "3.7.x" , nodeTypesVersion : "10.x" , minTarget : "es3" } ,
33
+
34
+ // 4.0
35
+ { tscVersion : "4.0" , nodeTypesVersion : "14.x" , minTarget : "es5" } ,
36
+
26
37
// 4.x
27
- { version : "4.x" , minTarget : "es3" } ,
38
+ { tscVersion : "4.x" , nodeTypesVersion : "18.x" , minTarget : "es6" } ,
39
+
40
+ // 5.x
41
+ { tscVersion : "5.x" , nodeTypesVersion : "22.x" , minTarget : "ES2022" } ,
28
42
]
29
43
30
44
// use ./typings-test.ts for tsc test, but change the import location for zmq
31
45
// to be used from `test/typings-compatibility/ts-x.x.x/typings-test.ts`:
32
- const zmqImportLoc = "../../../"
46
+ const zmqImportLoc = "../../../lib "
33
47
const srcFile = path . resolve ( __dirname , "typings-test.ts" )
34
48
const srcStr = readFile ( srcFile , "utf8" ) . then ( content => {
35
49
// replace import statement `import * as zmq from ...`:
@@ -71,9 +85,9 @@ async function run(
71
85
}
72
86
73
87
function getItLabelDetails ( tsVer : TestDef ) : string {
74
- const lbl = `v${ tsVer . version } for (minimal) compile target ${ JSON . stringify (
75
- tsVer . minTarget ,
76
- ) } `
88
+ const lbl = `v${
89
+ tsVer . tscVersion
90
+ } for (minimal) compile target ${ JSON . stringify ( tsVer . minTarget ) } `
77
91
if ( ! tsVer . requiredLibs || tsVer . requiredLibs . length === 0 ) {
78
92
return lbl
79
93
}
@@ -98,12 +112,15 @@ describe("compatibility of typings for typescript versions", async function () {
98
112
// the typescript package to complete
99
113
this . timeout ( 30000 )
100
114
101
- const tscTargetPath = path . resolve ( tscTestBasePath , `ts-${ tsVer . version } ` )
115
+ const tscTargetPath = path . resolve (
116
+ tscTestBasePath ,
117
+ `ts-${ tsVer . tscVersion } ` ,
118
+ )
102
119
103
120
it ( `it should compile successfully with typescript version ${
104
- tsVer . version
121
+ tsVer . tscVersion
105
122
// eslint-disable-next-line no-loop-func
106
- } , tsc ${ getItLabelDetails ( tsVer ) } `, async function ( ) {
123
+ } , tsc ${ getItLabelDetails ( tsVer ) } `, async ( ) => {
107
124
await prepareTestPackage ( tscTargetPath , tsVer , execCmd )
108
125
109
126
const cmd = [ "npm" , "pnpm" ] . includes ( execCmd ) ? `${ execCmd } run` : execCmd
@@ -146,8 +163,9 @@ async function prepareTestPackage(
146
163
path . resolve ( templateSrcPath , "package.json" ) ,
147
164
)
148
165
149
- pkgJson . name = `test-typings-ts-${ tsVer . version } `
150
- pkgJson . devDependencies . typescript = `${ tsVer . version } `
166
+ pkgJson . name = `test-typings-ts-${ tsVer . tscVersion } `
167
+ pkgJson . devDependencies . typescript = `${ tsVer . tscVersion } `
168
+ pkgJson . devDependencies [ "@types/node" ] = tsVer . nodeTypesVersion
151
169
return writeJson ( path . resolve ( tscTargetPath , "package.json" ) , pkgJson )
152
170
} ) ( ) ,
153
171
( async ( ) => {
0 commit comments