Skip to content

Commit

Permalink
explicitly type breach as any
Browse files Browse the repository at this point in the history
  • Loading branch information
codemist committed Jul 29, 2024
1 parent 514e99b commit 1808876
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/utils/breaches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,37 @@ async function bundleVerifiedEmails(
}

// get v2 "breach_resolution" object
const breachResolutionV2 = user.breach_resolution
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const breachResolutionV2: any = user.breach_resolution
? user.breach_resolution[email]
? user.breach_resolution[email]
: {}
: [];

const useBreachId = user.breach_resolution?.useBreachId;

// Not entirely sure what this section of the code is doing, but it's not typed
// There's inconsistency with the breaches data type, namely between HibpLikeDbBreach and SubscriberBreach
for (const breach of foundBreachesWithRecency) {
// if breach resolution json has `useBreachId` boolean, that means the migration has taken place
// we will use breach id as the key. Otherwise, we fallback to using recency index for backwards compatibility
if (useBreachId) {
breach.IsResolved = breachResolutionV2[breach.Id]?.isResolved;
breach.ResolutionsChecked =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(breach as any).IsResolved = breachResolutionV2[breach.Id]?.isResolved;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(breach as any).ResolutionsChecked =
breachResolutionV2[breach.Id]?.resolutionsChecked || [];
} else {
// TODO: remove after MNTOR-978
breach.IsResolved = breachResolutionV2[breach.recencyIndex]?.isResolved;
breach.ResolutionsChecked =
breachResolutionV2[breach.recencyIndex]?.resolutionsChecked || [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(breach as any).IsResolved =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
breachResolutionV2[(breach as any).recencyIndex]?.isResolved;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(breach as any).ResolutionsChecked =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
breachResolutionV2[(breach as any).recencyIndex]?.resolutionsChecked ||
[];
}

// filter breach types based on the 13 types we care about
Expand Down

0 comments on commit 1808876

Please sign in to comment.