Fix TypeScript errors from no-non-null-assertion fixes

Two fixes introduced by the non-null assertion cleanup produced type
errors:

- scoring-event.ts: `?? ""` was wrong type for a participant object map;
  restructured to explicit null guards so TypeScript can narrow correctly
- standings-sync/index.ts: `?? null` after name-match lookup lost the
  truthy guarantee, causing TS18047 on the write-back block; added
  `participant &&` guard before accessing its properties

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-03-21 10:56:40 -07:00
parent 13a36e6c41
commit c26573f435
2 changed files with 7 additions and 5 deletions

View file

@ -498,11 +498,13 @@ export async function getUpcomingEventsForDraftedParticipants(
const pMap = participantsByEvent.get(row.id); const pMap = participantsByEvent.get(row.id);
if (pMap) { if (pMap) {
if (row.participant1Id && draftedMap.has(row.participant1Id)) { if (row.participant1Id) {
pMap.set(row.participant1Id, draftedMap.get(row.participant1Id) ?? ""); const p1 = draftedMap.get(row.participant1Id);
if (p1) pMap.set(row.participant1Id, p1);
} }
if (row.participant2Id && draftedMap.has(row.participant2Id)) { if (row.participant2Id) {
pMap.set(row.participant2Id, draftedMap.get(row.participant2Id) ?? ""); const p2 = draftedMap.get(row.participant2Id);
if (p2) pMap.set(row.participant2Id, p2);
} }
} }

View file

@ -86,7 +86,7 @@ export async function syncStandings(sportsSeasonId: string): Promise<SyncResult>
if (matchedName) { if (matchedName) {
participant = participantByName.get(matchedName) ?? null; participant = participantByName.get(matchedName) ?? null;
// Write-back: persist externalId so future syncs skip name matching for this team // Write-back: persist externalId so future syncs skip name matching for this team
if (!participant.externalId) { if (participant && !participant.externalId) {
await updateParticipant(participant.id, { externalId: record.externalTeamId }); await updateParticipant(participant.id, { externalId: record.externalTeamId });
} }
} }