-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix missing option on typings #9
Conversation
I played around with this a bit locally and noticed the typings require all three arguments to be passed: // test.ts
import getOpts from "get-options";
console.log(getOpts(["--help", "--verbose"], {
"--help, -?": "",
"--verbose": "",
})); λ tsc test.ts
test.ts:2:13 - error TS2554: Expected 3 arguments, but got 2.
2 console.log(getOpts(["--help", "--verbose"], {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 "--help, -?": "",
~~~~~~~~~~~~~~~~~~~~~
4 "--verbose": "",
~~~~~~~~~~~~~~~~~~~~~
5 }));
~~
node_modules/get-options/index.d.ts:20:2
20 config: Config
~~~~~~~~~~~~~~
An argument for 'config' was not provided. Both the second and third arguments are actually optional ( Would it be possible to amend the typings to reflect this? |
I updated the PR |
…ethod according to microsoft
Thanks! Sorry for the delay. I decided I'm going to adjust the behaviour of The change of semantics is largely inspired by the need to parse environment variables like |
Hmm, good question. I guess if you want to start a new branch with your changes I can take a look at it and see what the typings would look like. Can you create a new version on npm 1.1.3 with the updates for the types? |
Shit! Sorry mate, I was meant to do this earlier, but I got sidetracked. 😞 Will cut a release now. |
Alright, the string-handling behaviour was implemented in diff --git a/index.d.ts b/index.d.ts
index b2a04b3..c8f2e1c 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -7,7 +7,7 @@
* Extract command-line options from a list of strings.
*/
declare function getOpts(
- input: any[],
+ input: string | any[],
optdef?: string | { [key: string]: string },
config?: getOpts.Config
): getOpts.Options; Hold off on any PRs though, I intend to add new options for features I've been wanting to implement. I'll ping you for review before cutting the next release. 😉 |
Fixed typings on missing option