Conversation
|
Can confirm that this fixes the issue I have reported originally. |
mleguen
left a comment
There was a problem hiding this comment.
I do think the unhandled rejection issue should be addressed before merging.
|
@bcoe IMO, we have a conception issue here: we should not accept async handlers in sync chained functions. I recommend:
|
What is the impact of breaking ability to chain methods? The last suggestion sounds reasonable. First one sounds like a quick workaround that will leave up to the individual yargs consumer to figure out their own way of handling async errors. |
|
This conception issue is what leads to your last test being so difficult to write. Any client program using async handlers and wanting to perform actions after yargs is done parsing will have the same problem: we cannot know when yargs is done parsing when using async handler. |
In fact, I think it would only prevent chaining However, the major impact would be that, when using async handlers, parse would no longer return directly the parsing results, but a promise. This would be great for people wanting to do things after parsing, but could break existing code. Next major release? |
|
In order not to block this fix, here is what I suggest:
@bcoe what is your opinion on this? |
|
@mleguen I'll take another stab at the patch with the I think we should avoid expanding on |
|
@mleguen ready for review 👍 |
This should address a couple minor issues that lead to #1144:
self.parsedwas being populated with anargvinstance rather than ayargsParser.detailedinstance, leading to the missing fields that raised exceptions.1.was addressed, the help message was incorrect, becauseasynchandlers prior to this relied on state not being reset; to solve this, we now cache the help message that would be displayed at the time of a promise's invocation.self.parsed, TypeScript executes all methods on a class, making our warning message display even though it wasn't explicitly invoked (I've reverted the warning message).TypeScript Issue:
@gajus could I get you to try this out?
fixes: #1144