Skip to content
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

mediawiki.api: Add custom Promise types #51

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

Derugon
Copy link
Collaborator

@Derugon Derugon commented Nov 14, 2024

Add custom Promise types to mw.Api and mw.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:

  • Reject/notify callback argument types are specified. Previously the 1st one was always specified as any, now respectively as string/number for most methods.
  • assertCurrentUser: The parameter assertUser is only added if the user is not anonymous. Previously the returned parameter type wrongly had it always specified.
  • loadMessagesIfMissing: May resolve to undefined if no valid messages were provided.
  • saveOptions: May resolve to undefined 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.

@Derugon Derugon merged commit a61a7e7 into wikimedia-gadgets:main Nov 22, 2024
1 check passed
@Derugon Derugon deleted the api-response branch November 22, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

abort() method absent on promises returned by mw.Api
1 participant