When utilizing the yargs builder with chained calls as demonstrated in the example below, everything functions correctly.
const foo = yargs(stringArray)
.string('bar')
.describe({
'bar': 'informative text',
}).argv;
However, attempting to achieve the same functionality by splitting it up and using the value of 'foo' appears to result in a breakage:
const foo = yargs(stringArray);
foo.string('bar')
.describe({
'bar': 'informative text',
}).argv; //this compiles but does not work
Coming from a Java background, I would assume that the first line returns a builder and whether I chain function calls or use a variable containing the output should not matter. However, in this case, it seems to not be the case. What am I overlooking? Is this specific to the library (in this instance, yargs) or is this a general behavior in TypeScript for this type of pattern?