Skip to content

Commit

Permalink
docs: add Typescript example for .terminalWidth() (#2224)
Browse files Browse the repository at this point in the history
Add example note of `.wrap()` method usage with `.terminalWidth()`.

Ref: #165 (comment)

Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
nelson6e65 and bcoe committed Nov 3, 2022
1 parent 75b4d52 commit a1b2eb7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/typescript.md
Expand Up @@ -121,6 +121,23 @@ interface Arguments {
}
```

If you need to use [`.wrap()`](https://yargs.js.org/docs/#api-reference-wrapcolumns) with `.terminalWidth()`, you may need to create instance first:

```ts
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

// ...

const yargsInstance = yargs(hideBin(process.argv));

cosnt args = yargsInstance
.wrap(myYargs.terminalWidth())
// .otherMethods(...)
.argv

```

# More specific typing for choices()

To improve the `choices` option typing you can also specify it as const:
Expand Down

0 comments on commit a1b2eb7

Please sign in to comment.