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
feat: add generics to OptionValues #1537
feat: add generics to OptionValues #1537
Conversation
This looks like it is functional, but I want to experiment a bit. I 'm not expert with generics and the current signatures don't give the cues I expect. The
Example usage:
|
How about this? The
|
Wow. Looks better than my PR. |
done |
Oh, even tidier with not needing to specify default. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested tests for index.test-d.ts
with the // opts
tests.
interface MyCheeseOption {
cheese: string;
}
const myCheeseOption = program.opts<MyCheeseOption>();
expectType<string>(myCheeseOption.cheese);
// @ts-expect-error Check that options strongly typed and does not allow arbitrary properties
expectType(myCheeseOption.foo);
The next release will be based on I don't mind sorting it out though, so optional for you to change the base branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reminder to self: don't merge onto |
PR moved to #1539 |
Pull Request
Problem
close #1536
Solution
TypeScript typings
ChangeLog