Add types for js globals (#31586)

Adds types for `window.config` and jQuery/htmx globals, eliminating 48
`tsc` errors.
This commit is contained in:
silverwind 2024-07-11 12:20:51 +02:00 committed by GitHub
parent 1b0ccf4bea
commit 228c354b16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 48 additions and 4 deletions

View file

@ -4,8 +4,8 @@ import {showErrorToast} from './modules/toast.ts';
import 'idiomorph/dist/idiomorph-ext.js';
// https://htmx.org/reference/#config
htmx.config.requestClass = 'is-loading';
htmx.config.scrollIntoViewOnBoost = false;
window.htmx.config.requestClass = 'is-loading';
window.htmx.config.scrollIntoViewOnBoost = false;
// https://htmx.org/events/#htmx:sendError
document.body.addEventListener('htmx:sendError', (event) => {

23
web_src/js/types.ts Normal file
View file

@ -0,0 +1,23 @@
export type MentionValue = {
key: string,
value: string,
name: string,
fullname: string,
avatar: string,
}
export type Config = {
appUrl: string,
appSubUrl: string,
assetVersionEncoded: string,
assetUrlPrefix: string,
runModeIsProd: boolean,
customEmojis: Record<string, string>,
csrfToken: string,
pageData: Record<string, any>,
notificationSettings: Record<string, any>,
enableTimeTracking: boolean,
mentionValues?: MentionValue[],
mermaidMaxSourceCharacters: number,
i18n: Record<string, string>,
}