refactor: update types (#19834)

This commit is contained in:
Alexander Akait 2025-08-25 16:36:05 +03:00 committed by GitHub
parent e570c1b5d1
commit e2ded49ee6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 17 deletions

View File

@ -161,21 +161,14 @@ const moreCount = (list, count) =>
* @template {object} O
* @template {keyof O} K
* @template {string} B
* @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? never : `${B}.${K}` : never} PropertyName
* @typedef {K extends string ? `${B}.${K}` : never} PropertyName
*/
/**
* @template {object} O
* @template {keyof O} K
* @template {string} B
* @typedef {K extends string ? NonNullable<O[K]> extends EXPECTED_ANY[] ? `${B}.${K}[]` : never : never} ArrayPropertyName
*/
/**
* @template {object} O
* @template {keyof O} K
* @template {string} B
* @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? `${B}.${K}` : never : never} MultiplePropertyName
* @typedef {K extends string ? `${B}.${K}[]` : never} ArrayPropertyName
*/
/**
@ -190,9 +183,7 @@ const moreCount = (list, count) =>
* @template {string} B
* @template {string} [R=B]
* @typedef {{ [K in keyof O as PropertyName<O, K, B>]?: SimplePrinter<O[K], R> } &
* { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never } &
* { [K in keyof O as MultiplePropertyName<O, K, B>]?: SimplePrinter<O[K], R> }
* } Printers
* { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never }} Printers
*/
/**
@ -1463,7 +1454,7 @@ const AVAILABLE_COLORS = {
* @typedef {T extends [infer Head, ...infer Tail] ? Tail : undefined} Tail
*/
/** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }>} AvailableFormats */
/** @typedef {{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }} AvailableFormats */
/** @type {AvailableFormats} */
const AVAILABLE_FORMATS = {
@ -1877,10 +1868,10 @@ class DefaultStatsPrinterPlugin {
}
for (const key of Object.keys(SIMPLE_ELEMENT_JOINERS)) {
const joiner = SIMPLE_ELEMENT_JOINERS[key];
stats.hooks.printElements
.for(key)
.tap(PLUGIN_NAME, /** @type {TODO} */ (joiner));
const joiner =
/** @type {(items: Item[], context: StatsPrinterContext) => string} */
(SIMPLE_ELEMENT_JOINERS[key]);
stats.hooks.printElements.for(key).tap(PLUGIN_NAME, joiner);
}
for (const key of Object.keys(RESULT_MODIFIER)) {