397
this.#globalMiddleware.addCoerceMiddleware(
398
(
400
>
yargs: YargsInstance
401
>
): Partial<Arguments> | Promise<Partial<Arguments>> => {
402
>
// Narrow down the possible keys to the ones present in argv.
403
>
const coerceKeyAliases = yargs.getAliases()[coerceKey] ?? [];
404
>
const argvKeys = [coerceKey, ...coerceKeyAliases].filter(key =>
405
>
Object.prototype.hasOwnProperty.call(argv, key)
406
>
);
407
>
408
>
// Skip coerce if nothing to coerce.
409
>
if (argvKeys.length === 0) {
410
return argv;
411
}