Disallow unsafe type assertions (#18688)

This commit is contained in:
Christian Gunderman
2026-02-10 00:10:15 +00:00
committed by GitHub
parent bce1caefd0
commit fd65416a2f
188 changed files with 592 additions and 47 deletions
+3
View File
@@ -68,6 +68,7 @@ function getNetworkErrorCode(error: unknown): string | undefined {
return undefined;
}
if ('code' in obj && typeof (obj as { code: unknown }).code === 'string') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
return (obj as { code: string }).code;
}
return undefined;
@@ -196,6 +197,7 @@ export async function retryWithBackoff<T>(
if (
shouldRetryOnContent &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
shouldRetryOnContent(result as GenerateContentResponse)
) {
const jitter = currentDelay * 0.3 * (Math.random() * 2 - 1);
@@ -327,6 +329,7 @@ export async function retryWithBackoff<T>(
// Generic retry logic for other errors
if (
attempt >= maxAttempts ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
!shouldRetryOnError(error as Error, retryFetchErrors)
) {
throw error;