Skip to content

Commit 6e110b0

Browse files
authored
Fix: Update for compliance with typescript 5.9.2 (#5855)
* update for compliance with typescript 5.9.2 * add non-optional emitter to all event types; misc type fixes * update known unknown types * fix EmitParameters type
1 parent 900cffc commit 6e110b0

File tree

7 files changed

+519
-469
lines changed

7 files changed

+519
-469
lines changed

ace-internal.d.ts

Lines changed: 92 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -423,133 +423,133 @@ export namespace Ace {
423423
* Emitted when the document changes.
424424
* @param delta
425425
*/
426-
"change": (delta: Delta) => void;
426+
"change": (delta: Delta, emitter: EditSession) => void;
427427
/**
428428
* Emitted when the tab size changes, via [[EditSession.setTabSize]].
429429
*/
430-
"changeTabSize": () => void;
430+
"changeTabSize": (e: undefined, emitter: EditSession) => void;
431431
/**
432432
* Emitted when the ability to overwrite text changes, via [[EditSession.setOverwrite]].
433433
* @param overwrite
434434
*/
435-
"changeOverwrite": (overwrite: boolean) => void;
435+
"changeOverwrite": (overwrite: boolean, emitter: EditSession) => void;
436436
/**
437437
* Emitted when the gutter changes, either by setting or removing breakpoints, or when the gutter decorations change.
438438
* @param e
439439
*/
440-
"changeBreakpoint": (e?: { row?: number, breakpoint?: boolean }) => void;
440+
"changeBreakpoint": (e: { row?: number, breakpoint?: boolean }, emitter: EditSession) => void;
441441
/**
442442
* Emitted when a front marker changes.
443443
*/
444-
"changeFrontMarker": () => void;
444+
"changeFrontMarker": (e: undefined, emitter: EditSession) => void;
445445
/**
446446
* Emitted when a back marker changes.
447447
*/
448-
"changeBackMarker": () => void;
448+
"changeBackMarker": (e: undefined, emitter: EditSession) => void;
449449
/**
450450
* Emitted when an annotation changes, like through [[EditSession.setAnnotations]].
451451
*/
452-
"changeAnnotation": (e: {}) => void;
452+
"changeAnnotation": (e: {}, emitter: EditSession) => void;
453453
/**
454454
* Emitted when a background tokenizer asynchronously processes new rows.
455455
*/
456-
"tokenizerUpdate": (e: { data: { first: number, last: number } }) => void;
456+
"tokenizerUpdate": (e: { data: { first: number, last: number } }, emitter: EditSession) => void;
457457
/**
458458
* Emitted when the current mode changes.
459459
* @param e
460460
*/
461-
"changeMode": (e: any) => void;
461+
"changeMode": (e: any, emitter: EditSession) => void;
462462
/**
463463
* Emitted when the wrap mode changes.
464464
* @param e
465465
*/
466-
"changeWrapMode": (e: any) => void;
466+
"changeWrapMode": (e: any, emitter: EditSession) => void;
467467
/**
468468
* Emitted when the wrapping limit changes.
469469
* @param e
470470
*/
471-
"changeWrapLimit": (e: any) => void;
471+
"changeWrapLimit": (e: any, emitter: EditSession) => void;
472472
/**
473473
* Emitted when a code fold is added or removed.
474474
* @param e
475475
*/
476-
"changeFold": (e: any, session?: EditSession) => void;
476+
"changeFold": (e: any, emitter: EditSession) => void;
477477
/**
478478
* Emitted when the scroll top changes.
479479
* @param scrollTop The new scroll top value
480480
**/
481-
"changeScrollTop": (scrollTop: number) => void;
481+
"changeScrollTop": (scrollTop: number, emitter: EditSession) => void;
482482
/**
483483
* Emitted when the scroll left changes.
484484
* @param scrollLeft The new scroll left value
485485
**/
486-
"changeScrollLeft": (scrollLeft: number) => void;
487-
"changeEditor": (e: { editor?: Editor, oldEditor?: Editor }) => void;
488-
"changeSelection": () => void;
489-
"startOperation": (op?: { command?: { name?: string }, args?: any }) => void;
490-
"endOperation": (op?: any) => void;
491-
"beforeEndOperation": () => void;
486+
"changeScrollLeft": (scrollLeft: number, emitter: EditSession) => void;
487+
"changeEditor": (e: { editor?: Editor, oldEditor?: Editor }, emitter: EditSession) => void;
488+
"changeSelection": (e: undefined, emitter: EditSession) => void;
489+
"startOperation": (op: { command?: { name?: string }, args?: any }, emitter: EditSession) => void;
490+
"endOperation": (op: any, emitter: EditSession) => void;
491+
"beforeEndOperation": (e: undefined, emitter: EditSession) => void;
492492
}
493493

494494
interface EditorEvents {
495-
"change": (delta: Delta) => void;
496-
"changeSelection": () => void;
497-
"input": () => void;
495+
"change": (delta: Delta, emitter: Editor) => void;
496+
"changeSelection": (e: undefined, emitter: Editor) => void;
497+
"input": (e: undefined, emitter: Editor) => void;
498498
/**
499499
* Emitted whenever the [[EditSession]] changes.
500500
* @param e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s.
501501
**/
502-
"changeSession": (e: { oldSession: EditSession, session: EditSession }) => void;
503-
"blur": (e: any) => void;
504-
"mousedown": (e: MouseEvent) => void;
505-
"mousemove": (e: MouseEvent & { scrollTop?: any }, editor?: Editor) => void;
506-
"changeStatus": (e: any) => void;
507-
"keyboardActivity": (e: any) => void;
508-
"mousewheel": (e: MouseEvent) => void;
509-
"mouseup": (e: MouseEvent) => void;
510-
"beforeEndOperation": (e: any) => void;
511-
"nativecontextmenu": (e: any) => void;
512-
"destroy": (e: any) => void;
513-
"focus": (e?: any) => void;
502+
"changeSession": (e: { oldSession: EditSession, session: EditSession }, emitter: Editor) => void;
503+
"blur": (e: any, emitter: Editor) => void;
504+
"mousedown": (e: MouseEvent, emitter: Editor) => void;
505+
"mousemove": (e: MouseEvent & { scrollTop?: any }, emitter: Editor) => void;
506+
"changeStatus": (e: any, emitter: Editor) => void;
507+
"keyboardActivity": (e: any, emitter: Editor) => void;
508+
"mousewheel": (e: MouseEvent, emitter: Editor) => void;
509+
"mouseup": (e: MouseEvent, emitter: Editor) => void;
510+
"beforeEndOperation": (e: any, emitter: Editor) => void;
511+
"nativecontextmenu": (e: any, emitter: Editor) => void;
512+
"destroy": (e: any, emitter: Editor) => void;
513+
"focus": (e: any, emitter: Editor) => void;
514514
/**
515515
* Emitted when text is copied.
516516
* @param text The copied text
517517
**/
518-
"copy": (e: { text: string }) => void;
518+
"copy": (e: { text: string }, emitter: Editor) => void;
519519
/**
520520
* Emitted when text is pasted.
521521
**/
522-
"paste": (e: { text: string, event?: ClipboardEvent }) => void;
522+
"paste": (e: { text: string, event?: ClipboardEvent }, emitter: Editor) => void;
523523
/**
524524
* Emitted when the selection style changes, via [[Editor.setSelectionStyle]].
525525
* @param data Contains one property, `data`, which indicates the new selection style
526526
**/
527-
"changeSelectionStyle": (data: "fullLine" | "screenLine" | "text" | "line") => void;
528-
"changeMode": (e: { mode?: Ace.SyntaxMode, oldMode?: Ace.SyntaxMode }) => void;
527+
"changeSelectionStyle": (data: "fullLine" | "screenLine" | "text" | "line", emitter: Editor) => void;
528+
"changeMode": (e: { mode?: Ace.SyntaxMode, oldMode?: Ace.SyntaxMode }, emitter: Editor) => void;
529529

530530
//from searchbox extension
531-
"findSearchBox": (e: { match: boolean }) => void;
531+
"findSearchBox": (e: { match: boolean }, emitter: Editor) => void;
532532

533533
//from code_lens extension
534-
"codeLensClick": (e: any) => void;
534+
"codeLensClick": (e: any, emitter: Editor) => void;
535535

536-
"select": () => void;
537-
"gutterkeydown": (e: GutterKeyboardEvent) => void;
538-
"gutterclick": (e: MouseEvent) => void;
539-
"showGutterTooltip": (e: GutterTooltip) => void;
540-
"hideGutterTooltip": (e: GutterTooltip) => void;
541-
"compositionStart": () => void;
536+
"select": (e: undefined, emitter: Editor) => void;
537+
"gutterkeydown": (e: GutterKeyboardEvent, emitter: Editor) => void;
538+
"gutterclick": (e: MouseEvent, emitter: Editor) => void;
539+
"showGutterTooltip": (e: GutterTooltip, emitter: Editor) => void;
540+
"hideGutterTooltip": (e: GutterTooltip, emitter: Editor) => void;
541+
"compositionStart": (e: undefined, emitter: Editor) => void;
542542
}
543543

544544
interface AcePopupEvents {
545-
"click": (e: MouseEvent) => void;
546-
"dblclick": (e: MouseEvent) => void;
547-
"tripleclick": (e: MouseEvent) => void;
548-
"quadclick": (e: MouseEvent) => void;
549-
"show": () => void;
550-
"hide": () => void;
551-
"select": (hide: boolean) => void;
552-
"changeHoverMarker": (e: any) => void;
545+
"click": (e: MouseEvent, emitter: AcePopup) => void;
546+
"dblclick": (e: MouseEvent, emitter: AcePopup) => void;
547+
"tripleclick": (e: MouseEvent, emitter: AcePopup) => void;
548+
"quadclick": (e: MouseEvent, emitter: AcePopup) => void;
549+
"show": (e: undefined, emitter: AcePopup) => void;
550+
"hide": (e: undefined, emitter: AcePopup) => void;
551+
"select": (hide: boolean, emitter: AcePopup) => void;
552+
"changeHoverMarker": (e: any, emitter: AcePopup) => void;
553553
}
554554

555555
interface DocumentEvents {
@@ -564,8 +564,8 @@ export namespace Ace {
564564
* * `lines`: the lines being removed
565565
*
566566
**/
567-
"change": (e: Delta) => void;
568-
"changeNewLineMode": () => void;
567+
"change": (e: Delta, emitter: Document) => void;
568+
"changeNewLineMode": (e: undefined, emitter: Document) => void;
569569
}
570570

571571
interface AnchorEvents {
@@ -577,7 +577,7 @@ export namespace Ace {
577577
* - `old`: An object describing the old Anchor position
578578
* - `value`: An object describing the new Anchor position
579579
**/
580-
"change": (e: { old: Point, value: Point }) => void;
580+
"change": (e: { old: Point, value: Point }, emitter: Anchor) => void;
581581
}
582582

583583
interface BackgroundTokenizerEvents {
@@ -587,52 +587,57 @@ export namespace Ace {
587587
**/
588588
"update": (e: {
589589
data: { first: number, last: number }
590-
}) => void;
590+
}, emitter: import("./src/background_tokenizer").BackgroundTokenizer) => void;
591591
}
592592

593593
interface SelectionEvents {
594594
/**
595595
* Emitted when the cursor position changes.
596596
**/
597-
"changeCursor": () => void;
597+
"changeCursor": (e: undefined, emitter: Selection) => void;
598598
/**
599599
* Emitted when the cursor selection changes.
600600
**/
601-
"changeSelection": () => void;
601+
"changeSelection": (e: undefined, emitter: Selection) => void;
602602
}
603603

604604
interface MultiSelectionEvents extends SelectionEvents {
605-
"multiSelect": () => void;
606-
"addRange": (e: { range: Range }) => void;
607-
"removeRange": (e: { ranges: Range[] }) => void;
608-
"singleSelect": () => void;
605+
"multiSelect": (e: undefined, emitter: Selection) => void;
606+
"addRange": (e: { range: Range }, emitter: Selection) => void;
607+
"removeRange": (e: { ranges: Range[] }, emitter: Selection) => void;
608+
"singleSelect": (e: undefined, emitter: Selection) => void;
609609
}
610610

611611
interface PlaceHolderEvents {
612-
"cursorEnter": (e: any) => void;
613-
"cursorLeave": (e: any) => void;
612+
"cursorEnter": (e: any, emitter: import("./src/placeholder").PlaceHolder) => void;
613+
"cursorLeave": (e: any, emitter: import("./src/placeholder").PlaceHolder) => void;
614614
}
615615

616616
interface GutterEvents {
617-
"changeGutterWidth": (width: number) => void;
618-
"afterRender": () => void;
617+
"changeGutterWidth": (width: number, emitter: import("./src/layer/gutter").Gutter) => void;
618+
"afterRender": (e: undefined, emitter: import("./src/layer/gutter").Gutter) => void;
619619
}
620620

621621
interface TextEvents {
622-
"changeCharacterSize": (e: any) => void;
622+
"changeCharacterSize": (e: any, emitter: import("./src/layer/text").Text) => void;
623623
}
624624

625625
interface VirtualRendererEvents {
626-
"afterRender": (e?: any, renderer?: VirtualRenderer) => void;
627-
"beforeRender": (e: any, renderer?: VirtualRenderer) => void;
628-
"themeLoaded": (e: { theme: string | Theme }) => void;
629-
"themeChange": (e: { theme: string | Theme }) => void;
630-
"scrollbarVisibilityChanged": () => void;
631-
"changeCharacterSize": (e: any) => void;
632-
"resize": (e?: any) => void;
633-
"autosize": () => void;
626+
"afterRender": (e: any, emitter: VirtualRenderer) => void;
627+
"beforeRender": (e: any, emitter: VirtualRenderer) => void;
628+
"themeLoaded": (e: { theme: string | Theme }, emitter: VirtualRenderer) => void;
629+
"themeChange": (e: { theme: string | Theme }, emitter: VirtualRenderer) => void;
630+
"scrollbarVisibilityChanged": (e: undefined, emitter: VirtualRenderer) => void;
631+
"changeCharacterSize": (e: any, emitter: VirtualRenderer) => void;
632+
"resize": (e: any, emitter: VirtualRenderer) => void;
633+
"autosize": (e: undefined, emitter: VirtualRenderer) => void;
634634
}
635635

636+
type EmitParameters<T extends (...args: any[]) => any> =
637+
T extends (first: infer First, ...rest: any[]) => any
638+
? [First]
639+
: [];
640+
636641
export class EventEmitter<T extends { [K in keyof T]: (...args: any[]) => any }> {
637642
once<K extends keyof T>(name: K, callback: T[K]): void;
638643

@@ -652,11 +657,11 @@ export namespace Ace {
652657

653658
removeAllListeners(name?: string): void;
654659

655-
_signal<K extends keyof T>(eventName: K, ...args: Parameters<T[K]>): void;
660+
_signal<K extends keyof T>(eventName: K, ...args: EmitParameters<T[K]>): void;
656661

657-
_emit<K extends keyof T>(eventName: K, ...args: Parameters<T[K]>): void;
662+
_emit<K extends keyof T>(eventName: K, ...args: EmitParameters<T[K]>): void;
658663

659-
_dispatchEvent<K extends keyof T>(eventName: K, ...args: Parameters<T[K]>): void;
664+
_dispatchEvent<K extends keyof T>(eventName: K, ...args: EmitParameters<T[K]>): void;
660665
}
661666

662667
interface SearchOptions {
@@ -951,7 +956,7 @@ export namespace Ace {
951956
editor: Editor,
952957
command: Command,
953958
args: any[]
954-
}) => void;
959+
}, emitter: CommandManager) => void;
955960

956961
interface CommandManagerEvents {
957962
"exec": execEventHandler
@@ -1290,21 +1295,21 @@ export namespace Ace {
12901295
}
12911296

12921297
export interface CommandBarEvents {
1293-
"hide": () => void;
1294-
"show": () => void;
1295-
"alwaysShow": (e: boolean) => void;
1298+
"hide": (e: undefined, emitter: import("./src/ext/command_bar").CommandBarTooltip) => void;
1299+
"show": (e: undefined, emitter: import("./src/ext/command_bar").CommandBarTooltip) => void;
1300+
"alwaysShow": (e: boolean, emitter: import("./src/ext/command_bar").CommandBarTooltip) => void;
12961301
}
12971302

12981303
export interface FontMetricsEvents {
1299-
"changeCharacterSize": (e: { data: { height: number, width: number } }) => void;
1304+
"changeCharacterSize": (e: { data: { height: number, width: number } }, emitter: import("./src/layer/font_metrics").FontMetrics) => void;
13001305
}
13011306

13021307
export interface OptionPanelEvents {
1303-
"setOption": (e: { name: string, value: any }) => void;
1308+
"setOption": (e: { name: string, value: any }, emitter: import("./src/ext/options").OptionPanel) => void;
13041309
}
13051310

13061311
export interface ScrollbarEvents {
1307-
"scroll": (e: { data: number }) => void;
1312+
"scroll": (e: { data: number }, emitter: ScrollBar) => void;
13081313
}
13091314

13101315
export interface TextInputAriaOptions {

0 commit comments

Comments
 (0)