When using the builder provided by yargs with chained calls like the following example, everything works fine.
const foo = yargs(stringArray)
.string('bar')
.describe({
'bar': 'informative text',
}).argv;
But when trying to achive the same code by splitting it and using the value of foo, it seems to break:
const foo = yargs(stringArray);
foo.string('bar')
.describe({
'bar': 'informative text',
}).argv; //this does compile, but not work
Coming from a Java background I would assume that the first line returns a builder and it would not matter if I chain the function calls or call it on a variable containing the output of the first line. That seems not to be the case here. What am I missing? Has this something to do with the library (in this case it's yargs) or is this general behavior in typescript for this kind of pattern?