You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am trying to use the usage command as a default alias as described in the docs here, using typescript as follows:
#!/usr/bin/env node
importyargsfrom'yargs/yargs';constargv=yargs(process.argv.slice(2)).usage('$0 <port>','start the application server',(yargs)=>{yargs.positional('port',{describe: 'the port that your application should bind to',type: 'number'})}).parseSync()console.log(argv)
However, when I go to compile this, I get the following error:
blah - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'string' is not assignable to parameter of type 'boolean'.
6 .usage('$0 <port>', 'start the application server', (yargs) => {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/yargs/index.d.ts:637:9
637 usage<O extends { [key: string]: Options }>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
638 command: string | ReadonlyArray<string>,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
641 handler?: (args: ArgumentsCamelCase<InferredOptionTypes<O>>) => void | Promise<void>,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
642 ): Argv<T>;
~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
EDIT: the yargs version is 17.7.1
Any help is greatly appreciated.
Best wishes,
Mat
The text was updated successfully, but these errors were encountered:
Thanks for the complete example application. The TypeScript definition expects the builder function to return the freshly configured yargs instance. Here, I have just added a return in your builder function.
constargv=yargs(process.argv.slice(2)).usage('$0 <port>','start the application server',(yargs)=>{returnyargs.positional('port',{describe: 'the port that your application should bind to',type: 'number'})}).parseSync()
Hi, I am trying to use the usage command as a default alias as described in the docs here, using typescript as follows:
However, when I go to compile this, I get the following error:
EDIT: the yargs version is 17.7.1
Any help is greatly appreciated.
Best wishes,
Mat
The text was updated successfully, but these errors were encountered: