Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
jquery: Make `expectOne` helper function generic.
Lalit Kumar Singh8d7a9162e2ad
diff --git a/web/src/global.d.ts b/web/src/global.d.tsindex e0c92489624..c7c7cb2e58d 100644--- a/web/src/global.d.ts+++ b/web/src/global.d.ts@@ -23,7 +23,7 @@ declare namespace JQueryValidation {// eslint-disable-next-line @typescript-eslint/consistent-type-definitionsinterface JQuery {- expectOne(): JQuery;+ expectOne<T extends HTMLElement>(): JQuery<T>;get_offset_to_window(): DOMRect;tab(action?: string): this; // From web/third/bootstrapmodal(action?: string): this; // From web/third/bootstrapdiff --git a/web/src/setup.ts b/web/src/setup.tsindex e8822fd75a7..008a4bdf5e9 100644--- a/web/src/setup.ts+++ b/web/src/setup.ts@@ -26,10 +26,10 @@ $(() => {return this[0].getBoundingClientRect();};- $.fn.expectOne = function () {+ $.fn.expectOne = function <T>() {if (blueslip && this.length !== 1) {blueslip.error("Expected one element in jQuery set", {length: this.length});}- return this;+ return this as JQuery<T>;};});