Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Command parent property to TypeScript #1475

Merged
merged 1 commit into from Feb 20, 2021

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Feb 19, 2021

Pull Request

Problem

The parent property is not declared in the TypeScript typings. The common use case for it is accessing the global option values in an action handler, and I have shown this in multiple examples in comments.

Related: #1184 #1427 (comment)

Previously accessing cmd.parent would not have caused a Typescript error, but the typings are stricter in Commander 7 now we no longer store options values as properties by default (hurrah!). This might lead to requests for other properties to be declared too, but planning to only add them on demand rather than declare everything.

Still thinking about providing a higher level way of accessing global options (#1229 #1155) but don't have one yet!

Solution

Declare parent property on Command object.

ChangeLog

  • add parent property to TypeScript definition for Command

Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your quick response.

@shadowspawn shadowspawn merged commit e12ea2e into tj:develop Feb 20, 2021
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Feb 20, 2021
@shadowspawn shadowspawn deleted the feature/add-parent-to-types branch February 20, 2021 01:37
@shadowspawn shadowspawn mentioned this pull request Feb 28, 2021
4 tasks
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants