Skip to content

Commit fd60bd8

Browse files
committed
chore: enable noImplicitAny on build.js
1 parent 3dfb778 commit fd60bd8

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

lib/build.js

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* @import {AppHash, BuildResult} from './types/build';
3-
* @import {ApplicationElmJson} from './types/content';
3+
* @import {ApplicationElmJson, ElmJson} from './types/content';
44
* @import {VersionString} from './types/version';
55
* @import {Options, Template} from './types/options';
66
* @import {Path} from './types/path';
7-
* @import {CompileOptions} from '../vendor/types/node-elm-compiler';
7+
* @import {CompileOptions, Sources} from '../vendor/types/node-elm-compiler';
88
*/
99
const path = require('node:path');
1010
const crypto = require('node:crypto');
@@ -330,6 +330,11 @@ async function createTemplateProject(
330330
Benchmark.end(options, 'Create template project');
331331
}
332332

333+
/**
334+
* @param {Options} options
335+
* @param {string} userSrc
336+
* @param {ApplicationElmJson} elmJson
337+
*/
333338
function updateSourceDirectories(options, userSrc, elmJson) {
334339
let sourceDirectories = [
335340
...elmJson['source-directories'].map((directory) =>
@@ -352,13 +357,22 @@ function updateSourceDirectories(options, userSrc, elmJson) {
352357
};
353358
}
354359

360+
/**
361+
* @param {Options} options
362+
* @param {string} dest
363+
* @param {string} elmModulePath
364+
* @param {Sources} compileTargets
365+
* @param {string} elmBinary
366+
* @param {boolean} isReviewApp
367+
* @returns {Promise<string | null>}
368+
*/
355369
async function compileElmProject(
356370
options,
357371
dest,
358372
elmModulePath,
359373
compileTargets,
360374
elmBinary,
361-
isReviewAppApp
375+
isReviewApp
362376
) {
363377
/** @type {CompileOptions} */
364378
const compileOptions = {
@@ -376,6 +390,7 @@ async function compileElmProject(
376390
}
377391
};
378392

393+
/** @type {string | null} */
379394
const resolvedElmModulePath = await new Promise((resolve) => {
380395
const compileProcess = elmCompiler.compile(compileTargets, compileOptions);
381396

@@ -434,13 +449,13 @@ async function compileElmProject(
434449
}
435450
});
436451
});
437-
return await OptimizeJs.optimize(
438-
options,
439-
resolvedElmModulePath,
440-
isReviewAppApp
441-
);
452+
return await OptimizeJs.optimize(options, resolvedElmModulePath, isReviewApp);
442453
}
443454

455+
/**
456+
* @param {Options} options
457+
* @param {string} stderr
458+
*/
444459
function compilationError(options, stderr) {
445460
if (stderr.includes('DEBUG REMNANTS')) {
446461
return {
@@ -454,7 +469,7 @@ function compilationError(options, stderr) {
454469
return {
455470
title: 'MODULE NOT FOUND',
456471
// prettier-ignore
457-
message: `A module is missing in your configuration. Maybe you forgot to add some dependencies that contain the rules you wished to enable? If so, run ${chalk.magenta('elm install')} with the package name from inside ${chalk.yellow(options.userSrc(null))}.`
472+
message: `A module is missing in your configuration. Maybe you forgot to add some dependencies that contain the rules you wished to enable? If so, run ${chalk.magenta('elm install')} with the package name from inside ${chalk.yellow(options.userSrc())}.`
458473
};
459474
}
460475

@@ -477,6 +492,11 @@ function compilationError(options, stderr) {
477492
};
478493
}
479494

495+
/**
496+
* @param {Options} options
497+
* @param {Path} reviewElmJsonPath
498+
* @param {ElmJson} reviewElmJson
499+
*/
480500
function validateElmReviewVersion(options, reviewElmJsonPath, reviewElmJson) {
481501
if (options.localElmReviewSrc) {
482502
return;
@@ -530,6 +550,11 @@ of ${chalk.yellow(path.dirname(reviewElmJsonPath))}.`
530550
MinVersion.validate(options, reviewElmJsonPath, elmReviewVersion);
531551
}
532552

553+
/**
554+
* @param {Options} options
555+
* @param {ApplicationElmJson} reviewElmJson
556+
* @returns {Promise<void>}
557+
*/
533558
async function buildElmParser(options, reviewElmJson) {
534559
const elmSyntaxVersion =
535560
reviewElmJson.dependencies.direct['stil4m/elm-syntax'] ||
@@ -563,7 +588,7 @@ async function buildElmParser(options, reviewElmJson) {
563588
})
564589
]);
565590

566-
return await compileElmProject(
591+
await compileElmProject(
567592
options,
568593
buildFolder,
569594
elmParserPath,

lib/optimize-js.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ const FS = require('./fs-wrapper');
88

99
/**
1010
* @param {Options} options
11-
* @param {string} elmModulePath
12-
* @param {boolean} isReviewAppApp
13-
* @returns {Promise<string>}
11+
* @param {string | null} elmModulePath
12+
* @param {boolean} isReviewApp
13+
* @returns {Promise<string | null>}
1414
*/
15-
async function optimize(options, elmModulePath, isReviewAppApp) {
15+
async function optimize(options, elmModulePath, isReviewApp) {
1616
if (options.debug || !elmModulePath) {
1717
return elmModulePath;
1818
}
1919

20-
const timerId = isReviewAppApp
20+
const timerId = isReviewApp
2121
? 'optimizing review application'
2222
: 'optimizing parser application';
2323
Benchmark.start(options, timerId);
2424
const originalSource = await FS.readFile(elmModulePath);
25-
const replacements = isReviewAppApp
25+
const replacements = isReviewApp
2626
? [
2727
...performanceReplacements,
2828
...cacheReplacements(options.localElmReviewSrc)

tsconfig.no-implicit-any.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"lib/app-wrapper.js",
1111
"lib/autofix.js",
1212
"lib/benchmark.js",
13+
"lib/build.js",
1314
"lib/cache.js",
1415
"lib/debug.js",
1516
"lib/dependency-provider.js",

vendor/node-elm-compiler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function compilerErrorToString(err, pathToElm) {
133133
/**
134134
* @param {Sources} sources
135135
* @param {CompileOptions} options
136+
* @returns {ChildProcess}
136137
*/
137138
function compile(sources, options) {
138139
var optionsWithDefaults = prepareOptions(options, options.spawn || spawn);

0 commit comments

Comments
 (0)