fix: Phase 7d - fix null/undefined handling (28 -> 24 errors)

Fixed multiple null/undefined type errors by adding proper null checks
and default values.

Changes:
1. CharacterRep.svelte:
   - Changed import from '$lib/types/enums' to '$lib/utils/element'
   - getElementClass in utils/element accepts undefined, enums version doesn't

2. ItemHeader.svelte:
   - Convert null to undefined for gridUncapLevel and gridTranscendence
   - getCharacterPose expects 'number | undefined', not 'number | null | undefined'

3. UncapStatusDisplay.svelte:
   - Added null coalescing for transcendenceStep check
   - Changed from `transcendenceStep > 0` to `(transcendenceStep ?? 0) > 0`

4. base.adapter.ts:
   - Provide default no-op function for optional onError callback
   - Required<AdapterOptions> needs all properties defined

Result: 28 → 24 errors (-4)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-11-28 20:04:02 -08:00
parent 9fb2e2485d
commit e0810781f4
4 changed files with 4 additions and 4 deletions

View file

@ -68,7 +68,7 @@ export abstract class BaseAdapter {
timeout: options.timeout ?? 30000,
retries: options.retries ?? 3,
cacheTime: options.cacheTime ?? 0,
onError: options.onError
onError: options.onError ?? (() => {})
}
}

View file

@ -1,7 +1,7 @@
<script lang="ts">
import type { Party, GridWeapon, GridCharacter } from '$lib/types/api/party'
import type { Job } from '$lib/types/api/entities'
import { getElementClass } from '$lib/types/enums'
import { getElementClass } from '$lib/utils/element'
import { getCharacterImageWithPose } from '$lib/utils/images'
import { getJobPortraitUrl, Gender } from '$lib/utils/jobUtils'

View file

@ -23,7 +23,7 @@
const id = itemData?.granblueId
if (type === 'character') {
const pose = getCharacterPose(gridUncapLevel, gridTranscendence)
const pose = getCharacterPose(gridUncapLevel ?? undefined, gridTranscendence ?? undefined)
return getCharacterDetailImage(id, pose)
} else if (type === 'weapon') {
return getWeaponBaseImage(id)

View file

@ -92,7 +92,7 @@
<span class="badge" class:active={(uncapLevel ?? 0) >= 5}>ULB</span>
{/if}
{#if transcendence}
<span class="badge" class:active={transcendenceStep > 0}>Trans</span>
<span class="badge" class:active={(transcendenceStep ?? 0) > 0}>Trans</span>
{/if}
{#if !flb && !ulb && !transcendence}
<span class="badge standard">Standard</span>