data: Restrict parameter type to not be undefined.

Since the type of request_method(AjaxRequestHandler) has
been extended in the previous commit.Consequently the 'data'
field of 'request_method' has to be typed such that it
satisfies this change.

Because request_method's type can also be 'typeof patch' which
does not accept undefined 'data' field, I haved 'omit'-ted
'undefined' from 'data's type in function signature to satisfy
TypeScript.

Now ,in support of the changes I have made to two different function
sign(namely setting_ui.do_settings_change,dialog_widget.submit_api_request)
I am stating some points about data field inside these respective
function signs.

1.settings_ui.do_settings_change: For this 'data' was actually never
undefined. Each function call has a 'data' object passed( with one
or more fields).

2.dialog_widget.submit_api_request: For this case many function calls
actually didn't have 'data' field (ie.'data' was undefined).
BUT,for those cases it was defaulted to '{}'(see function sign).
So effectively 'request_method' didn't recieve an undefined 'data' for
this case too. I have removed the defaulting and passed '{}' in the
function calls for those cases, which effectively does the some job,
but satisfies the type.

For both these cases 'data' field isn't undefined and hence an Omit,for me
makes sense.
This commit is contained in:
Varun Singh
2024-04-04 07:06:46 +05:30
committed by Tim Abbott
parent 9b9ea01dfa
commit 9ad7a9f0be
8 changed files with 11 additions and 11 deletions

View File

@@ -98,7 +98,7 @@ function build_page(): void {
html_body,
id: "confirm_delete_code_playgrounds_modal",
on_click() {
dialog_widget.submit_api_request(channel.del, url);
dialog_widget.submit_api_request(channel.del, url, {});
},
loading_spinner: true,
});