Type AjaxRequestHandler is used for typing request methods
(like channel.get, channel.post etc.)Use cases include
'request_method' parameter in settings_ui.do_settings_change
and dialog_widget.submit_api_request.
Problem with the type definition:
The current type definition( ie. 'typeof call' ) satisfies every
'request_method' type EXCEPT channel.patch request.One can notice
the difference b/w 'call' and 'patch' function in channel.ts .
Hence,We need to expand the AjaxRequestHandler type.I have unioned it
with 'typeof patch' is account for the case when 'request_method'parameter
is of type channel.patch.
Discussion:
https://chat.zulip.org/#narrow/stream/6-frontend/topic/setting_ui.20do_settings_change/near/1754557
We should reuse the `channel.xhr_error_message` in `ui_report` to reduce
code duplication.
Also, I changed the type of `message` parameter to `string` instead of
`string | null` so that we do not need to alter the types of the functions
that depends on the return value of `xhr_error_message`.