Fix a number of typescript errors (#32773)

Fixes 96 typescript errors. Behaviour changes are commented below.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind 2024-12-11 09:29:04 +01:00 committed by GitHub
parent e619384098
commit 8a53a39c42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 81 additions and 80 deletions

View file

@ -1,7 +1,7 @@
import {hideElem, showElem, toggleElem} from '../utils/dom.ts';
import {GET} from '../modules/fetch.ts';
async function loadBranchesAndTags(area, loadingButton) {
async function loadBranchesAndTags(area: Element, loadingButton: Element) {
loadingButton.classList.add('disabled');
try {
const res = await GET(loadingButton.getAttribute('data-fetch-url'));
@ -15,7 +15,7 @@ async function loadBranchesAndTags(area, loadingButton) {
}
}
function addTags(area, tags) {
function addTags(area: Element, tags: Array<Record<string, any>>) {
const tagArea = area.querySelector('.tag-area');
toggleElem(tagArea.parentElement, tags.length > 0);
for (const tag of tags) {
@ -23,7 +23,7 @@ function addTags(area, tags) {
}
}
function addBranches(area, branches, defaultBranch) {
function addBranches(area: Element, branches: Array<Record<string, any>>, defaultBranch: string) {
const defaultBranchTooltip = area.getAttribute('data-text-default-branch-tooltip');
const branchArea = area.querySelector('.branch-area');
toggleElem(branchArea.parentElement, branches.length > 0);
@ -33,7 +33,7 @@ function addBranches(area, branches, defaultBranch) {
}
}
function addLink(parent, href, text, tooltip) {
function addLink(parent: Element, href: string, text: string, tooltip?: string) {
const link = document.createElement('a');
link.classList.add('muted', 'tw-px-1');
link.href = href;