@@ -6,11 +6,11 @@ import fsCb from 'node:fs'
6
6
import readline from 'node:readline'
7
7
import util from 'node:util'
8
8
9
- import AjvDraft04 from 'ajv-draft-04'
9
+ import _AjvDraft04 from 'ajv-draft-04'
10
10
import { Ajv as AjvDraft06And07 } from 'ajv'
11
- import Ajv2019 from 'ajv/dist/2019.js'
12
- import Ajv2020 from 'ajv/dist/2020.js'
13
- import addFormats from 'ajv-formats'
11
+ import _Ajv2019 from 'ajv/dist/2019.js'
12
+ import _Ajv2020 from 'ajv/dist/2020.js'
13
+ import _addFormats from 'ajv-formats'
14
14
import { ajvFormatsDraft2019 } from '@hyperupcall/ajv-formats-draft2019'
15
15
import schemasafe from '@exodus/schemasafe'
16
16
import TOML from 'smol-toml'
@@ -20,12 +20,30 @@ import * as jsoncParser from 'jsonc-parser'
20
20
import ora from 'ora'
21
21
import chalk from 'chalk'
22
22
import minimist from 'minimist'
23
- import fetch from 'node-fetch'
23
+ import fetch , { FetchError } from 'node-fetch'
24
24
25
25
/**
26
26
* @import { Ora } from 'ora'
27
27
*/
28
28
29
+ /**
30
+ * Ajv defines types, but they don't work when importing the library with
31
+ * ESM syntax. Tweaking `jsconfig.json` with `esModuleInterop` didn't seem
32
+ * to fix things, so manually set the types with a cast. This issue is
33
+ * tracked upstream at https://github.com/ajv-validator/ajv/issues/2132.
34
+ */
35
+ /** @type {typeof _AjvDraft04.default } */
36
+ const AjvDraft04 = /** @type {any } */ ( _AjvDraft04 )
37
+
38
+ /** @type {typeof _Ajv2019.default } */
39
+ const Ajv2019 = /** @type {any } */ ( _Ajv2019 )
40
+
41
+ /** @type {typeof _Ajv2020.default } */
42
+ const Ajv2020 = /** @type {any } */ ( _Ajv2020 )
43
+
44
+ /** @type {typeof _addFormats.default } */
45
+ const addFormats = /** @type {any } */ ( _addFormats )
46
+
29
47
// Declare constants.
30
48
const AjvDraft06SchemaJson = await readJsonFile (
31
49
'node_modules/ajv/dist/refs/json-schema-draft-06.json' ,
@@ -843,7 +861,9 @@ async function taskMaintenance() {
843
861
`NOT OK (${ res . status } /${ res . statusText } ): ${ url } (after 405 code)` ,
844
862
)
845
863
} catch ( err ) {
846
- console . info ( `NOT OK (${ err . code } ): ${ url } (after 405 code)` )
864
+ console . info (
865
+ `NOT OK (${ /** @type {FetchError } */ ( err ) . code } ): ${ url } (after 405 code)` ,
866
+ )
847
867
}
848
868
return
849
869
}
0 commit comments