Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e213889

Browse files
committed
Add return type defs=
1 parent 418acb0 commit e213889

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/auto-complete-element.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class AutocompleteElement extends HTMLElement {
88
super()
99
}
1010

11-
connectedCallback() {
11+
connectedCallback(): void {
1212
const listId = this.getAttribute('for')
1313
if (!listId) return
1414

@@ -19,7 +19,7 @@ export default class AutocompleteElement extends HTMLElement {
1919
results.setAttribute('role', 'listbox')
2020
}
2121

22-
disconnectedCallback() {
22+
disconnectedCallback(): void {
2323
const autocomplete = state.get(this)
2424
if (autocomplete) {
2525
autocomplete.destroy()
@@ -59,7 +59,7 @@ export default class AutocompleteElement extends HTMLElement {
5959
return ['open', 'value']
6060
}
6161

62-
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
62+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void {
6363
if (oldValue === newValue) return
6464

6565
const autocomplete = state.get(this)

src/autocomplete.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class Autocomplete {
3838
this.results.addEventListener('combobox-commit', this.onCommit)
3939
}
4040

41-
destroy() {
41+
destroy(): void {
4242
this.input.removeEventListener('keydown', this.onKeydown)
4343
this.input.removeEventListener('focus', this.onInputFocus)
4444
this.input.removeEventListener('blur', this.onInputBlur)
@@ -47,7 +47,7 @@ export default class Autocomplete {
4747
this.results.removeEventListener('combobox-commit', this.onCommit)
4848
}
4949

50-
onKeydown(event: KeyboardEvent) {
50+
onKeydown(event: KeyboardEvent): void {
5151
if (event.key === 'Escape' && this.container.open) {
5252
this.container.open = false
5353
event.stopPropagation()
@@ -64,19 +64,19 @@ export default class Autocomplete {
6464
}
6565
}
6666

67-
onInputFocus() {
67+
onInputFocus(): void {
6868
this.fetchResults()
6969
}
7070

71-
onInputBlur() {
71+
onInputBlur(): void {
7272
if (this.interactingWithList) {
7373
this.interactingWithList = false
7474
return
7575
}
7676
this.container.open = false
7777
}
7878

79-
onCommit({target}: Event) {
79+
onCommit({target}: Event): void {
8080
const selected = target
8181
if (!(selected instanceof HTMLElement)) return
8282
this.container.open = false
@@ -85,23 +85,23 @@ export default class Autocomplete {
8585
this.container.value = value
8686
}
8787

88-
onResultsMouseDown() {
88+
onResultsMouseDown(): void {
8989
this.interactingWithList = true
9090
}
9191

92-
onInputChange() {
92+
onInputChange(): void {
9393
this.container.removeAttribute('value')
9494
this.fetchResults()
9595
}
9696

97-
identifyOptions() {
97+
identifyOptions(): void {
9898
let id = 0
9999
for (const el of this.results.querySelectorAll('[role="option"]:not([id])')) {
100100
el.id = `${this.results.id}-option-${id++}`
101101
}
102102
}
103103

104-
fetchResults() {
104+
fetchResults(): void {
105105
const query = this.input.value.trim()
106106
if (!query) {
107107
this.container.open = false
@@ -132,13 +132,13 @@ export default class Autocomplete {
132132
})
133133
}
134134

135-
open() {
135+
open(): void {
136136
if (!this.results.hidden) return
137137
this.combobox.start()
138138
this.results.hidden = false
139139
}
140140

141-
close() {
141+
close(): void {
142142
if (this.results.hidden) return
143143
this.combobox.stop()
144144
this.results.hidden = true

0 commit comments

Comments
 (0)