mediawiki.api
: Add custom Promise
types
#51
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add custom
Promise
types tomw.Api
andmw.Rest
to fix #50.These types provide the missing
abort
method, and use tuples for callback argument types to help specifying multiple arguments.Most API/REST response callbacks are changed to be more specific (and fix some wrong types). For migration purpose, potentially breaking changes are listed below:
any
, now respectively asstring
/number
for most methods.assertCurrentUser
: The parameterassertUser
is only added if the user is not anonymous. Previously the returned parameter type wrongly had it always specified.loadMessagesIfMissing
: May resolve toundefined
if no valid messages were provided.saveOptions
: May resolve toundefined
if no options were provided. Note that if the argument types allow to deduce that at least one option has been provided, the callback argument types are narrowed accordingly.