Skip to content

Commit 08be1d5

Browse files
add return methods are typed
1 parent 54da0da commit 08be1d5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/autocomplete.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ interface Params {
2323
Input: Element;
2424

2525
// Workflow methods
26+
_Blur: any;
2627
_EmptyMessage: any;
28+
_Focus: any;
2729
_Limit: any;
2830
_Method: any;
29-
_ParamName: any;
30-
_Url: any;
31-
_Blur: any;
32-
_Focus: any;
3331
_OnKeyUp: any;
3432
_Open: any;
33+
_ParamName: any;
3534
_Position: any;
3635
_Post: any;
3736
_Pre: any;
3837
_Select: any;
38+
_Url: any;
3939
}
4040

4141
// Core
@@ -101,7 +101,7 @@ class AutoComplete {
101101

102102
return this.Url;
103103
},
104-
_Blur: function(now: boolean = false) {
104+
_Blur: function(now: boolean = false): void {
105105
console.log("Blur", "Close results div", this);
106106

107107
if (now) {
@@ -113,7 +113,7 @@ class AutoComplete {
113113
}, 150);
114114
}
115115
},
116-
_Focus: function() {
116+
_Focus: function(): void {
117117
console.log("Focus", "Open results div", this);
118118
var oldValue: string = this.Input.getAttribute("data-autocomplete-old-value");
119119
console.log("Old value setted in input attribute", oldValue);
@@ -122,7 +122,7 @@ class AutoComplete {
122122
this.DOMResults.setAttribute("class", "autocomplete open");
123123
}
124124
},
125-
_OnKeyUp: function(event: KeyboardEvent) {
125+
_OnKeyUp: function(event: KeyboardEvent): void {
126126
console.log("OnKeyUp", this, "KeyboardEvent", event);
127127

128128
var first = this.DOMResults.querySelector("li:first-child:not(.locked)"),
@@ -173,7 +173,7 @@ class AutoComplete {
173173
}
174174
}
175175
},
176-
_Open: function() {
176+
_Open: function(): void {
177177
console.log("Open", this);
178178
var params = this;
179179
Array.prototype.forEach.call(this.DOMResults.getElementsByTagName("li"), function(li) {
@@ -182,12 +182,12 @@ class AutoComplete {
182182
};
183183
});
184184
},
185-
_Position:function() {
185+
_Position:function(): void {
186186
console.log("Build results position", this);
187187
this.DOMResults.setAttribute("class", "autocomplete");
188188
this.DOMResults.setAttribute("style", "top:" + (this.Input.offsetTop + this.Input.offsetHeight) + "px;left:" + this.Input.offsetLeft + "px;width:" + this.Input.clientWidth + "px;");
189189
},
190-
_Post: function(response) {
190+
_Post: function(response): void {
191191
console.log("Post", this);
192192
try {
193193
response = JSON.parse(response);
@@ -253,14 +253,14 @@ class AutoComplete {
253253

254254
return this.Input.value;
255255
},
256-
_Select: function(item) {
256+
_Select: function(item): void {
257257
console.log("Select", this);
258258
this.Input.setAttribute("data-autocomplete-old-value", this.Input.value = item.getAttribute("data-autocomplete-value", item.innerHTML));
259259
},
260260
};
261261

262262
// Constructor
263-
constructor(params: Object = {}, selector: any = "[data-autocomplete]") {
263+
constructor(params: Object = {}, selector: any = "[data-autocomplete]"): void {
264264
if (Array.isArray(selector)) {
265265
selector.forEach(function(s: string) {
266266
new AutoComplete(params, s);
@@ -286,7 +286,7 @@ class AutoComplete {
286286
}
287287
}
288288

289-
create(params: Params) {
289+
create(params: Params): void {
290290
console.log("Object", params);
291291

292292
if (params.Input.nodeName.match(/^INPUT$/i) && params.Input.getAttribute("type").match(/^TEXT|SEARCH$/i)) {
@@ -306,7 +306,7 @@ class AutoComplete {
306306
}
307307
}
308308

309-
ajax(params: Params) {
309+
ajax(params: Params): void {
310310
console.log("AJAX", params);
311311
if (params.Request) {
312312
params.Request.abort();
@@ -339,7 +339,7 @@ class AutoComplete {
339339
params.Request.send(queryParams);
340340
}
341341

342-
destroy(params: Params) {
342+
destroy(params: Params): void {
343343
console.log("Destroy event received", params);
344344

345345
params.Input.removeEventListener("position", params._Position);

0 commit comments

Comments
 (0)