Skip to content

Commit

Permalink
cleanup our type definitions
Browse files Browse the repository at this point in the history
this fixes one inconsistency with the .d.ts
(focus & blur return the BaseMathQuill rather than void)

this also gets rid of some deduplication by making EditableMathQuill extend
BaseMathQuill, to match the structure of publicapi.ts
  • Loading branch information
eluberoff committed Sep 18, 2024
1 parent d1cca35 commit c272cf4
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions src/mathquill.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,27 @@ declare namespace MathQuill {
interface BaseMathQuill {
id: number;
data: { [key: string]: any };
config(opts: Config): BaseMathQuill;
config<T extends BaseMathQuill>(opts: Config): T;
revert: () => HTMLElement;
latex(latex: string): BaseMathQuill;
latex<T extends BaseMathQuill>(latex: string): T;
latex(): string;
reflow: () => void;
el: () => HTMLElement;
getAriaLabel(): string;
setAriaLabel(str: string): BaseMathQuill;
setAriaLabel<T extends BaseMathQuill>(str: string): T;
html: () => string;
mathspeak: () => string;
text(): string;
blur: () => void;
focus: () => void;
blur<T extends BaseMathQuill>(): T;
focus<T extends BaseMathQuill>(): T;
selection(): {
latex: string;
startIndex: number;
endIndex: number;
};
}

interface EditableMathQuill {
id: number;
data: { [key: string]: any };
revert: () => HTMLElement;
config(opts: Config): EditableMathQuill;
latex(latex: string): EditableMathQuill;
latex(): string;
reflow: () => void;
el: () => HTMLElement;
getAriaLabel(): string;
setAriaLabel(str: string): EditableMathQuill;
html: () => string;
mathspeak: () => string;
text(): string;
selection(): {
latex: string;
startIndex: number;
endIndex: number;
};
interface EditableMathQuill extends BaseMathQuill {
select: () => EditableMathQuill;
moveToRightEnd: () => EditableMathQuill;
moveToLeftEnd: () => EditableMathQuill;
Expand All @@ -69,8 +51,6 @@ declare namespace MathQuill {
keystroke: (key: string, evt?: KeyboardEvent) => EditableMathQuill;
typedText: (text: string) => EditableMathQuill;
clearSelection: () => EditableMathQuill;
blur: () => EditableMathQuill;
focus: () => EditableMathQuill;
getAriaPostLabel: () => string;
setAriaPostLabel: (str: string, timeout?: number) => EditableMathQuill;
ignoreNextMousedown: (func: () => boolean) => EditableMathQuill;
Expand Down

0 comments on commit c272cf4

Please sign in to comment.