fix: resolve all TypeScript strict null check errors

Fix ~68 pre-existing strict null errors across 13 feature modules.
Add non-null assertions for DOM element lookups, null coalescing for
optional values, and type guards for nullable properties. Zero tsc
errors now with --noEmit.
This commit is contained in:
2026-03-24 13:59:07 +03:00
parent c0d0d839dc
commit 1111ab7355
13 changed files with 85 additions and 75 deletions

View File

@@ -41,19 +41,19 @@ const syncClockModal = new SyncClockModal();
export async function showSyncClockModal(editData: SyncClock | null): Promise<void> {
const isEdit = !!editData;
const titleKey = isEdit ? 'sync_clock.edit' : 'sync_clock.add';
document.getElementById('sync-clock-modal-title').innerHTML = `${ICON_CLOCK} ${t(titleKey)}`;
(document.getElementById('sync-clock-id') as HTMLInputElement).value = isEdit ? editData.id : '';
document.getElementById('sync-clock-modal-title')!.innerHTML = `${ICON_CLOCK} ${t(titleKey)}`;
(document.getElementById('sync-clock-id') as HTMLInputElement).value = editData?.id || '';
(document.getElementById('sync-clock-error') as HTMLElement).style.display = 'none';
if (isEdit) {
(document.getElementById('sync-clock-name') as HTMLInputElement).value = editData.name || '';
(document.getElementById('sync-clock-speed') as HTMLInputElement).value = String(editData.speed ?? 1.0);
document.getElementById('sync-clock-speed-display').textContent = String(editData.speed ?? 1.0);
document.getElementById('sync-clock-speed-display')!.textContent = String(editData.speed ?? 1.0);
(document.getElementById('sync-clock-description') as HTMLInputElement).value = editData.description || '';
} else {
(document.getElementById('sync-clock-name') as HTMLInputElement).value = '';
(document.getElementById('sync-clock-speed') as HTMLInputElement).value = String(1.0);
document.getElementById('sync-clock-speed-display').textContent = '1';
document.getElementById('sync-clock-speed-display')!.textContent = '1';
(document.getElementById('sync-clock-description') as HTMLInputElement).value = '';
}
@@ -230,10 +230,10 @@ export function createSyncClockCard(clock: SyncClock) {
${renderTagChips(clock.tags)}
${clock.description ? `<div class="template-config" style="opacity:0.7;">${escapeHtml(clock.description)}</div>` : ''}`,
actions: `
<button class="btn btn-icon btn-secondary" data-action="${toggleAction}" data-id="${clock.id}" title="${toggleTitle}">${clock.is_running ? ICON_PAUSE : ICON_START}</button>
<button class="btn btn-icon btn-secondary" data-action="reset" data-id="${clock.id}" title="${t('sync_clock.action.reset')}">${ICON_CLOCK}</button>
<button class="btn btn-icon btn-secondary" data-action="clone" data-id="${clock.id}" title="${t('common.clone')}">${ICON_CLONE}</button>
<button class="btn btn-icon btn-secondary" data-action="edit" data-id="${clock.id}" title="${t('common.edit')}">${ICON_EDIT}</button>`,
<button class="btn btn-icon btn-secondary" data-action="${toggleAction}" title="${toggleTitle}">${clock.is_running ? ICON_PAUSE : ICON_START}</button>
<button class="btn btn-icon btn-secondary" data-action="reset" title="${t('sync_clock.action.reset')}">${ICON_CLOCK}</button>
<button class="btn btn-icon btn-secondary" data-action="clone" title="${t('common.clone')}">${ICON_CLONE}</button>
<button class="btn btn-icon btn-secondary" data-action="edit" title="${t('common.edit')}">${ICON_EDIT}</button>`,
});
}
@@ -253,12 +253,13 @@ export function initSyncClockDelegation(container: HTMLElement): void {
if (!btn) return;
// Only handle actions within a sync-clock card (data-id on card root)
const card = btn.closest<HTMLElement>('[data-id]');
const section = btn.closest<HTMLElement>('[data-card-section="sync-clocks"]');
if (!card || !section) return;
if (!section) return;
const card = btn.closest<HTMLElement>('[data-id]');
if (!card) return;
const action = btn.dataset.action;
const id = btn.dataset.id;
const id = card.getAttribute('data-id');
if (!action || !id) return;
const handler = _syncClockActions[action];