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
Middleware type definitions don’t match actual API #2360
Labels
Comments
The types available for client use are from DefinitelyTyped, and maintained separately. You might want to open an issue/discussion over there too. For comparison, the definition used internally in yargs is: Lines 121 to 125 in e517318
And for interest related to the internal typings: #1751 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It’s currently not that easy to write middlewares in TypeScript, because the actual API and exported types seem to be out of sync.
This is a legitimate Yargs middleware:
Which can be verified by looking directly at the API code.
yargs/lib/middleware.ts
Lines 111 to 114 in e517318
However, this is the corresponding type definition I am consuming:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3a6d407361cc6025d136ae5eb3c3e3e24ada5009/types/yargs/v16/index.d.ts#L838
The problems with that:
MiddlewareFunction
is not documented.YargsInstance
doesn’t seem to be accessible.void
, but the API user can actually decide between modifying the originalargs
(args.foo = 'bar'; return
) and letting Yargs do the merging (const changes = {}; changes.foo = 'bar'; return changes
).The text was updated successfully, but these errors were encountered: