-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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(yargs): type 'string' is not assignable to type '"string"' #28061
Conversation
Reasoning for change. There is logic built into the interface Options where the property of types must be either the value of "string", "number" , etc. However, the type of the input is just a string. Having the logic built in makes it unusable.
In my project, I have the following error in my CircleCI: Transpile errors due to
When applying the fix in the PR to the local node_modules/@types/yargs, the error disappears. |
@cnishina Thank you for submitting this PR! 🔔 @poelstra @mizunashi-mana @pushplay @jeffkenney @JimiC - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
@cnishina I'm afraid this is the wrong approach. The definition for In case |
It does follow the Options interface.
Your comment above says my |
And the PositionalOptionsType is defined as: If the value of However, if they actually can take on those types, then it should be:
|
Have a look at the official docs. |
I do see that using
complains but
is more than fine. I'll investigate further why the definition complains. |
Now when I use
the complain goes away. |
New error with yargs.OptionsIt works for
Should we cast into
|
@JimiC @andy-ms Please see comment above. |
|
Again please review the part about the boolean. |
also works fine. |
Maybe it's best to use |
Well I'm not sure. Let's see, I'm running: [email protected] This fails on my computer and circleci. https://circleci.com/gh/cnishina/webdriver-manager-replacement/128 |
Here is me adding the object into the Is your opinion here that this is only my issue and should not be merged? This feels like a lot of push back for my issue that I've investigated and also described. |
I don't think this is right. It should be typed strongly but we should let the |
It does because typescript does an internal type check. |
Let me explain further.
is a valid variable declaration for typescript, but it's an invalid Now if you write it as
typescript immediately infers that it's not a valid Your change, on the other hand, will allow this declaration and it's not valid according to the official I hope I made myself clear and why your PR is invalid. |
Again, comment above is that interfaces are just objects. When writing out this interface, if I satisfy that the type of This is not productive and I think we need another person to weigh in. @andy-ms. Thoughts? |
@andy-ms is not a member of the authoring team. |
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.
PR is invalid.
I spoke too soon that it is a runtime error. There is no runtime error so maybe the logic in typings is fine until we fix yargs. |
@cnishina One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. Thank you! |
Is the revision to close the PR? I think this is the wrong label. |
One last thing:
is valid. There's nothing wrong with this... yargs just figures out what type it is when the option is used. |
- Do not use yarg typings until DefinitelyTyped/DefinitelyTyped#28061 is resolved. - Created e2e test to updates, checks status, starts server, and removes files. - Expose seleniumProcess from the SeleniumServer class. - Moved SIGINT event to start handler method. This will let a user stop the selenium sever with the process pid and without existing their JavaScript process.
- Do not use yarg typings until DefinitelyTyped/DefinitelyTyped#28061 is resolved. - Created e2e test to updates, checks status, starts server, and removes files. - Expose seleniumProcess from the SeleniumServer class. - Moved SIGINT event to start handler method. This will let a user stop the selenium sever with the process pid and without existing their JavaScript process.
- Do not use yarg typings until DefinitelyTyped/DefinitelyTyped#28061 is resolved. - Created e2e test to updates, checks status, starts server, and removes files. - Expose seleniumProcess from the SeleniumServer class. - Moved SIGINT event to start handler method. This will let a user stop the selenium sever with the process pid and without existing their JavaScript process.
- Do not use yargs typings until DefinitelyTyped/DefinitelyTyped#28061 is resolved. - Created e2e test to updates, checks status, starts server, and removes files. - Expose seleniumProcess from the SeleniumServer class. - Moved SIGINT event to start handler method. This will let a user stop the selenium sever with the process pid and without existing their JavaScript process.
- Do not use yargs typings until DefinitelyTyped/DefinitelyTyped#28061 is resolved. - Created e2e test to updates, checks status, starts server, and removes files. - Expose seleniumProcess from the SeleniumServer class. - Moved SIGINT event to start handler method. This will let a user stop the selenium sever with the process pid and without existing their JavaScript process.
- Do not use yargs typings until DefinitelyTyped/DefinitelyTyped#28061 is resolved. - Created e2e test to updates, checks status, starts server, and removes files. - Expose seleniumProcess from the SeleniumServer class. - Moved SIGINT event to start handler method. This will let a user stop the selenium sever with the process pid and without existing their JavaScript process. closes #24
See microsoft/TypeScript#25889 -- string literals need a contextual type to avoid being turned into |
Since this is my first project with yargs, I was not sure if I was using yargs wrong or not. For the most part, the yargs type definitions did help but things did not go well when I started using the It looks like you have this: microsoft/TypeScript#26413 which will help debugging messages for string literals in interfaces. If the error message said I needed to cast into the In its current state, I am still not a fan with the error message but I will close the PR. Thank you @andy-ms for being referee / third party opinion. Thank you @JimiC for debugging this with me. |
Reasoning for change. There is logic built into the interface Options where the property of types must be either the value of "string", "number" , etc. However, the type of the input is just a string. Having the logic built in makes it unusable.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).