@@ -6,11 +6,11 @@ import fsCb from 'node:fs'
66import readline from 'node:readline'
77import util from 'node:util'
88
9- import AjvDraft04 from 'ajv-draft-04'
9+ import _AjvDraft04 from 'ajv-draft-04'
1010import { 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'
1414import { ajvFormatsDraft2019 } from '@hyperupcall/ajv-formats-draft2019'
1515import schemasafe from '@exodus/schemasafe'
1616import TOML from 'smol-toml'
@@ -20,12 +20,30 @@ import * as jsoncParser from 'jsonc-parser'
2020import ora from 'ora'
2121import chalk from 'chalk'
2222import minimist from 'minimist'
23- import fetch from 'node-fetch'
23+ import fetch , { FetchError } from 'node-fetch'
2424
2525/**
2626 * @import { Ora } from 'ora'
2727 */
2828
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+
2947// Declare constants.
3048const AjvDraft06SchemaJson = await readJsonFile (
3149 'node_modules/ajv/dist/refs/json-schema-draft-06.json' ,
@@ -843,7 +861,9 @@ async function taskMaintenance() {
843861 `NOT OK (${ res . status } /${ res . statusText } ): ${ url } (after 405 code)` ,
844862 )
845863 } 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+ )
847867 }
848868 return
849869 }
0 commit comments