I am upgrading the yargs version from 16.2.0 to 17.4.0 in order to use the async builder feature, but after upgrading, our sub commands do not work well because the global property seems being broken.
I write a piece of code for testing the global property and the true reason may be the coerce property conflicts with the global.
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
yargs(hideBin(process.argv))
.command("new", "new a project", async (yargs) => {
return yargs
.options("op1", {
description: "option1",
default: "option1",
global: false,
type: "string",
coerce: (arg?: string) => arg?.toLocaleLowerCase(), // if comment this line, it works well.
})
.command(
"template",
"new a project from a template",
async (yargs) => {
return yargs.options("op2", {
description: "option2",
default: "option2",
});
},
async (args: any) => {
console.log(args);
}
);
})
.strict()
.help().argv;
The following is the result when run this code.

Is this a bug or there are some different usages about the global property?
Thanks.
I am upgrading the
yargsversion from16.2.0to17.4.0in order to use the async builder feature, but after upgrading, our sub commands do not work well because theglobalproperty seems being broken.I write a piece of code for testing the
globalproperty and the true reason may be thecoerceproperty conflicts with theglobal.The following is the result when run this code.

Is this a bug or there are some different usages about the global property?
Thanks.