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

Strongly typed optsWithGlobals #78

Merged
merged 6 commits into from
Nov 1, 2024

Conversation

shadowspawn
Copy link
Contributor

@shadowspawn shadowspawn commented Oct 26, 2024

Pull Request

Problem

.optsWithGlobals() and .getOptionValueSourceWithGlobals() are weakly typed and not using globals.

Solution

Add Command<> generic for GlobalOpts.

  • .optsWithGlobals() is strongly typed
  • .getOptionValueSourceWithGlobals() is weakly typed. Get autocompletion for known options, but can enter anything, like with the other ...Source... routines.

On the way I upgraded eslint because I noticed @typescript-eslint/ban-types was changing to @typescript-eslint/no-empty-object-type. And simplified eslint.config.js to avoid bogus TypeScript errors from .js files. (Apologies for the extra changes. I did make them separate commits.)

ChangeLog

  • strongly type .optsWithGlobals() to include inferred globals
  • weakly type .getOptionValueSourceWithGlobals() to include inferred globals

@shadowspawn shadowspawn force-pushed the feature/strongly-typed-globals branch from 40f902d to c08000c Compare October 27, 2024 04:40
@shadowspawn shadowspawn changed the base branch from develop to release/13.x October 27, 2024 05:20
@shadowspawn shadowspawn force-pushed the feature/strongly-typed-globals branch from dbfe3f2 to acbc92c Compare October 27, 2024 05:23
@shadowspawn shadowspawn marked this pull request as ready for review October 27, 2024 05:25
@shadowspawn shadowspawn changed the title Feature/strongly typed globals Strongly typed optsWithGlobals Oct 27, 2024
@shadowspawn shadowspawn added the pending release On a branch for eventual release, but not yet merged to main. label Nov 1, 2024
@shadowspawn shadowspawn merged commit 8649fe9 into release/13.x Nov 1, 2024
18 checks passed
@shadowspawn shadowspawn deleted the feature/strongly-typed-globals branch November 1, 2024 21:00
@donaldinho
Copy link

@shadowspawn @abetomo do you know when this will be released?

@shadowspawn
Copy link
Contributor Author

We don't have a date planned, but I expect by mid-January 2026.

Would a pre-release build be useful to you?

I have just one more issue I want to look at for a major version of Commander:

@donaldinho
Copy link

donaldinho commented Nov 29, 2024 via email

@shadowspawn
Copy link
Contributor Author

A prerelease is available for v13. The release is tagged as next and can be installed with:

npm install @commander-js/extra-typings@next

@shadowspawn
Copy link
Contributor Author

Released in v13.0.0

@shadowspawn shadowspawn removed the pending release On a branch for eventual release, but not yet merged to main. label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants