Skip to content

Commit dc19f82

Browse files
chore: fix todo types (#19550)
1 parent 598767e commit dc19f82

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

lib/ChunkGroup.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,23 @@ class ChunkGroup {
115115
*/
116116
addOptions(options) {
117117
for (const _key of Object.keys(options)) {
118-
const key = /** @type {keyof ChunkGroupOptions} */ (_key);
118+
const key =
119+
/** @type {keyof ChunkGroupOptions} */
120+
(_key);
119121
if (this.options[key] === undefined) {
120-
/** @type {TODO} */
122+
/** @type {EXPECTED_ANY} */
121123
(this.options)[key] = options[key];
122124
} else if (this.options[key] !== options[key]) {
123125
if (key.endsWith("Order")) {
124-
/** @type {TODO} */
125-
(this.options)[key] = Math.max(
126-
/** @type {number} */ (this.options[key]),
127-
/** @type {number} */ (options[key])
126+
const orderKey =
127+
/** @type {Exclude<keyof ChunkGroupOptions, "name" | "fetchPriority">} */
128+
(key);
129+
130+
this.options[orderKey] = Math.max(
131+
/** @type {number} */
132+
(this.options[orderKey]),
133+
/** @type {number} */
134+
(options[orderKey])
128135
);
129136
} else {
130137
throw new Error(

lib/Compilation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
23542354
*/
23552355
_addEntryItem(context, entry, target, options, callback) {
23562356
const { name } = options;
2357+
/** @type {EntryData | undefined} */
23572358
let entryData =
23582359
name !== undefined ? this.entries.get(name) : this.globalEntry;
23592360
if (entryData === undefined) {

lib/stats/DefaultStatsPrinterPlugin.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,12 @@ const AVAILABLE_COLORS = {
14541454
magenta: "\u001B[1m\u001B[35m"
14551455
};
14561456

1457-
/** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContext, ...args: TODO[]) => string }>} AvailableFormats */
1457+
/**
1458+
* @template T
1459+
* @typedef {T extends [infer Head, ...infer Tail] ? Tail : undefined} Tail
1460+
*/
1461+
1462+
/** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }>} AvailableFormats */
14581463

14591464
/** @type {AvailableFormats} */
14601465
const AVAILABLE_FORMATS = {
@@ -1629,21 +1634,16 @@ class DefaultStatsPrinterPlugin {
16291634
context[color] = str => str;
16301635
}
16311636
}
1632-
for (const format of Object.keys(AVAILABLE_FORMATS)) {
1637+
for (const _format of Object.keys(AVAILABLE_FORMATS)) {
1638+
const format =
1639+
/** @type {keyof KnownStatsPrinterFormatters} */
1640+
(_format);
1641+
16331642
context[format] =
1634-
/**
1635-
* @param {string | number} content content
1636-
* @param {...TODO} args args
1637-
* @returns {string} result
1638-
*/
1643+
/** @type {(content: Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>[0], ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>>) => string} */
16391644
(content, ...args) =>
16401645
/** @type {TODO} */
1641-
(
1642-
AVAILABLE_FORMATS[
1643-
/** @type {keyof AvailableFormats} */
1644-
(format)
1645-
]
1646-
)(
1646+
(AVAILABLE_FORMATS)[format](
16471647
content,
16481648
/** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
16491649
(context),

0 commit comments

Comments
 (0)