diff --git a/new-package/elm-review-package-tests/check-previews-compile.js b/new-package/elm-review-package-tests/check-previews-compile.js index 73621f648..067a0ac7d 100644 --- a/new-package/elm-review-package-tests/check-previews-compile.js +++ b/new-package/elm-review-package-tests/check-previews-compile.js @@ -14,6 +14,9 @@ for (const example of findPreviewConfigurations()) { checkThatExampleCompiles(example); } +/** + * @param {string} exampleConfiguration + */ function checkThatExampleCompiles(exampleConfiguration) { const exampleConfigurationElmJson = require(`${exampleConfiguration}/elm.json`); @@ -62,10 +65,17 @@ and make the necessary changes to make it compile.` } } +/** + * @param {string} config + */ function success(config) { console.log(`${Ansi.green('✔')} ${path.relative(root, config)}/ compiles`); } +/** + * @param {string} exampleConfiguration + * @param {Record} previewDependencies + */ function checkDepsAreCompatible(exampleConfiguration, previewDependencies) { for (const [depName, constraint] of Object.entries(packageDependencies)) { if (!(depName in previewDependencies)) { @@ -94,6 +104,12 @@ function checkDepsAreCompatible(exampleConfiguration, previewDependencies) { } } +/** + * @param {string} exampleConfiguration + * @param {string} depName + * @param {string} constraint + * @param {string} version + */ function checkConstraint(exampleConfiguration, depName, constraint, version) { const [minVersion] = constraint.split(' <= v < ').map(splitVersion); const previewVersion = splitVersion(version); @@ -110,6 +126,11 @@ function checkConstraint(exampleConfiguration, depName, constraint, version) { } } +/** + * @param {string} version + */ function splitVersion(version) { - return version.split('.').map((n) => Number.parseInt(n, 10)); + return version + .split('.') + .map((/** @type {string} */ n) => Number.parseInt(n, 10)); } diff --git a/new-package/elm-review-package-tests/helpers/ansi.js b/new-package/elm-review-package-tests/helpers/ansi.js index fee727b7d..5eaa78f5a 100644 --- a/new-package/elm-review-package-tests/helpers/ansi.js +++ b/new-package/elm-review-package-tests/helpers/ansi.js @@ -1,13 +1,22 @@ +/** + * @param {string} text + */ function red(text) { - return '\u001B[31m' + text + '\u001B[39m'; + return `\u001B[31m${text}\u001B[39m`; } +/** + * @param {string} text + */ function green(text) { - return '\u001B[32m' + text + '\u001B[39m'; + return `\u001B[32m${text}\u001B[39m`; } +/** + * @param {string} text + */ function yellow(text) { - return '\u001B[33m' + text + '\u001B[39m'; + return `\u001B[33m${text}\u001B[39m`; } module.exports = { diff --git a/new-package/maintenance/update-examples-from-preview.js b/new-package/maintenance/update-examples-from-preview.js index 9d16a5bec..32b86f49e 100755 --- a/new-package/maintenance/update-examples-from-preview.js +++ b/new-package/maintenance/update-examples-from-preview.js @@ -16,6 +16,18 @@ if (require.main === module) { // Find all elm.json files +/** + * @typedef {object} ApplicationElmJson + * @property {string[]} source-directories + * @property {DependencyList} dependencies + */ + +/** + * @typedef {object} DependencyList + * @property {Record} direct + * @property {Record} indirect + */ + function copyPreviewsToExamples() { const previewFolders = findPreviewConfigurations(); for (const folder of previewFolders) { @@ -23,6 +35,9 @@ function copyPreviewsToExamples() { } } +/** + * @param {string} pathToPreviewFolder + */ function copyPreviewToExample(pathToPreviewFolder) { const pathToExampleFolder = `${pathToPreviewFolder}/`.replace( /preview/g, @@ -32,7 +47,10 @@ function copyPreviewToExample(pathToPreviewFolder) { fs.copySync(pathToPreviewFolder, pathToExampleFolder, {overwrite: true}); const pathToElmJson = path.resolve(pathToExampleFolder, 'elm.json'); - const elmJson = fs.readJsonSync(pathToElmJson); + const elmJson = + /** @type {{ ['source-directories']: string[], dependencies: {direct: Record} }} */ ( + fs.readJsonSync(pathToElmJson) + ); // Remove the source directory pointing to the package's src/ elmJson['source-directories'] = elmJson['source-directories'].filter( diff --git a/tsconfig.no-implicit-any.json b/tsconfig.no-implicit-any.json index dd7cd7fb1..af21ac845 100644 --- a/tsconfig.no-implicit-any.json +++ b/tsconfig.no-implicit-any.json @@ -58,6 +58,7 @@ "lib/template-dependencies.js", "lib/utils.js", "lib/watch.js", + "new-package/elm-review-package-tests/*.js", "test/jest-helpers/cli.js", "test/jest-helpers/types/cli.ts", "test/flags.test.js",