@@ -7,7 +7,20 @@ import {getIssueColor, getIssueIcon} from '../issue.ts';
7
7
import { debounce } from 'perfect-debounce' ;
8
8
import type TextExpanderElement from '@github/text-expander-element' ;
9
9
10
- const debouncedSuggestIssues = debounce ( ( key : string , text : string ) => new Promise < { matched :boolean ; fragment ?: HTMLElement } > ( async ( resolve ) => {
10
+ type TextExpanderProvideResult = {
11
+ matched : boolean ,
12
+ fragment ?: HTMLElement ,
13
+ }
14
+
15
+ type TextExpanderChangeEvent = Event & {
16
+ detail ?: {
17
+ key : string ,
18
+ text : string ,
19
+ provide : ( result : TextExpanderProvideResult | Promise < TextExpanderProvideResult > ) => void ,
20
+ }
21
+ }
22
+
23
+ const debouncedSuggestIssues = debounce ( ( key : string , text : string ) => new Promise < TextExpanderProvideResult > ( async ( resolve ) => {
11
24
const issuePathInfo = parseIssueHref ( window . location . href ) ;
12
25
if ( ! issuePathInfo . ownerName ) {
13
26
const repoOwnerPathInfo = parseRepoOwnerPathInfo ( window . location . pathname ) ;
@@ -34,7 +47,8 @@ const debouncedSuggestIssues = debounce((key: string, text: string) => new Promi
34
47
} ) , 100 ) ;
35
48
36
49
export function initTextExpander ( expander : TextExpanderElement ) {
37
- expander ?. addEventListener ( 'text-expander-change' , ( { detail : { key, provide, text} } : Record < string , any > ) => {
50
+ expander ?. addEventListener ( 'text-expander-change' , ( e : TextExpanderChangeEvent ) => {
51
+ const { key, text, provide} = e . detail ;
38
52
if ( key === ':' ) {
39
53
const matches = matchEmoji ( text ) ;
40
54
if ( ! matches . length ) return provide ( { matched : false } ) ;
0 commit comments