Nested object options and TypeScript aren't compatible
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Using object options
If I want to pass object options, like tool --bq.project=zzz
then how should I describe the option?
I tried as
.option(
'bq.project',
{type: 'string', description: 'GCP project id for BigQuery'})
but in TypeScript it doesn't work.
I do see intellisence for argv['bq.project'] but it's not correct (it returns undefined), the correct call is argv.bg.project, but in TypeScript is not legal, because argv has no 'bq' field.
Of cause with the casting (<any>argv.bq).project it works, but it's ugly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/tricks.md's object-options guidance and reproduce the bq.project example from the issue. Inspect how the option declaration and argv access are typed; done means nested object options have accurate TypeScript access without an any cast.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- cli, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100