Disallow underspecified types (#21485)

This commit is contained in:
Christian Gunderman
2026-03-07 21:05:38 +00:00
committed by GitHub
parent 245b68e9f1
commit dac3735626
18 changed files with 51 additions and 7 deletions
+1
View File
@@ -112,6 +112,7 @@ Return ONLY the corrected string in the specified JSON format with the key 'corr
if (
result &&
// eslint-disable-next-line no-restricted-syntax
typeof result['corrected_string_escaping'] === 'string' &&
result['corrected_string_escaping'].length > 0
) {
+1
View File
@@ -209,6 +209,7 @@ export function parseGoogleApiError(error: unknown): GoogleApiError | null {
}
// Basic structural check before casting.
// Since the proto definitions are loose, we primarily rely on @type presence.
// eslint-disable-next-line no-restricted-syntax
if (typeof detailObj['@type'] === 'string') {
// We can just cast it; the consumer will have to switch on @type
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
+5
View File
@@ -361,19 +361,24 @@ async function parseTokenEndpointResponse(
data &&
typeof data === 'object' &&
'access_token' in data &&
// eslint-disable-next-line no-restricted-syntax
typeof (data as Record<string, unknown>)['access_token'] === 'string'
) {
const obj = data as Record<string, unknown>;
const result: OAuthTokenResponse = {
access_token: String(obj['access_token']),
token_type:
// eslint-disable-next-line no-restricted-syntax
typeof obj['token_type'] === 'string' ? obj['token_type'] : 'Bearer',
expires_in:
// eslint-disable-next-line no-restricted-syntax
typeof obj['expires_in'] === 'number' ? obj['expires_in'] : undefined,
refresh_token:
// eslint-disable-next-line no-restricted-syntax
typeof obj['refresh_token'] === 'string'
? obj['refresh_token']
: undefined,
// eslint-disable-next-line no-restricted-syntax
scope: typeof obj['scope'] === 'string' ? obj['scope'] : undefined,
};
return result;