Fix compiler errors in public/global.d.ts (#4464) * Fix TS1038 errors "A 'declare' modifier cannot be used in an already ambient context." * Fix TS1040 errors "'async' modifier cannot be used in an ambient context." * Fix TS2371 errors "A parameter initializer is only allowed in a function or constructor implementation." * Fix TS2430 errors "Interface 'ColorPickerEvent' incorrectly extends interface 'ChangeEvent<HTMLElement, any, any, any>'". The issue here is that the "ColorPickerEvent" objects provided by toolcool-color-picker.js are vanilla JS CustomEvent objects, not JQuery event objects. We need to mangle the types here a bit to make JQuery happy. (At runtime, JQuery is happy to pass along the vanilla Event object; JQuery's types just don't reflect this.) * Remove variable and type exports --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -5,20 +5,20 @@ import { QuickReplyApi } from './scripts/extensions/quick-reply/api/QuickReplyAp | |||
| 5 | 5 | ||
| 6 | declare global { | 6 | declare global { |
| 7 | // Custom types | 7 | // Custom types |
| 8 | declare type InstructSettings = typeof power_user.instruct; | 8 | type InstructSettings = typeof power_user.instruct; |
| 9 | declare type ContextSettings = typeof power_user.context; | 9 | type ContextSettings = typeof power_user.context; |
| 10 | declare type ReasoningSettings = typeof power_user.reasoning; | 10 | type ReasoningSettings = typeof power_user.reasoning; |
| 11 | 11 | ||
| 12 | // Global namespace modules | 12 | // Global namespace modules |
| 13 | interface Window { | 13 | interface Window { |
| 14 | ai: any; | 14 | ai: any; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | declare var pdfjsLib; | 17 | var pdfjsLib; |
| 18 | declare var ePub; | 18 | var ePub; |
| 19 | declare var quickReplyApi: QuickReplyApi; | 19 | var quickReplyApi: QuickReplyApi; |
| 20 | 20 | ||
| 21 | declare var SillyTavern: { | 21 | var SillyTavern: { |
| 22 | getContext(): typeof getContext; | 22 | getContext(): typeof getContext; |
| 23 | llm: any; | 23 | llm: any; |
| 24 | libs: typeof libs; | 24 | libs: typeof libs; |
| @@ -63,7 +63,7 @@ declare global { | |||
| 63 | * @param lang Target language | 63 | * @param lang Target language |
| 64 | * @param provider Translation provider | 64 | * @param provider Translation provider |
| 65 | */ | 65 | */ |
| 66 | async function translate(text: string, lang: string, provider: string = null): Promise<string>; | 66 | function translate(text: string, lang: string, provider?: string | null): Promise<string>; |
| 67 | 67 | ||
| 68 | interface ConvertVideoArgs { | 68 | interface ConvertVideoArgs { |
| 69 | buffer: Uint8Array; | 69 | buffer: Uint8Array; |
| @@ -76,9 +76,9 @@ declare global { | |||
| 76 | */ | 76 | */ |
| 77 | function convertVideoToAnimatedWebp(args: ConvertVideoArgs): Promise<Uint8Array>; | 77 | function convertVideoToAnimatedWebp(args: ConvertVideoArgs): Promise<Uint8Array>; |
| 78 | 78 | ||
| 79 | interface ColorPickerEvent extends JQuery.ChangeEvent<HTMLElement> { | 79 | type ColorPickerEvent = Omit<JQuery.ChangeEvent<HTMLElement>, "detail"> & { |
| 80 | detail: { | 80 | detail: { |
| 81 | rgba: string; | 81 | rgba: string; |
| 82 | }; | 82 | } |
| 83 | } | 83 | }; |
| 84 | } | 84 | } |