From 952f9fd954c90c1e19ed3c9312d164c220c62845 Mon Sep 17 00:00:00 2001 From: Burak Keskin Date: Sun, 30 Aug 2026 21:57:46 +0300 Subject: [PATCH] fix: do not treat option value 1 as a count increment --- lib/yargs-parser.ts | 10 ++++++++-- test/yargs-parser.mjs | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/yargs-parser.ts b/lib/yargs-parser.ts index 48a2d0f2..ac1954b6 100644 --- a/lib/yargs-parser.ts +++ b/lib/yargs-parser.ts @@ -626,7 +626,8 @@ export class YargsParser { // increment a count given as arg (either no value or value parsed as boolean) if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) { - value = increment() + // COUNT_INCREMENT is a unique sentinel, not the number 1. + value = COUNT_INCREMENT as unknown as typeof value } // Set normalized value when key is in 'normalize' and in 'arrays' @@ -850,7 +851,7 @@ export class YargsParser { } } - if (value === increment()) { + if (value === COUNT_INCREMENT) { o[key] = increment(o[key]) } else if (Array.isArray(o[key])) { if (duplicate && isTypeArray && isValueArray) { @@ -1098,6 +1099,11 @@ function combineAliases (aliases: Dictionary): Dictionary