fix(auth-service): 修复 AlipayProvider TypeScript 类型错误 (unknown 类型断言)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-04 04:47:01 -08:00
parent 1fc0fcb95e
commit e8e2a44fef
1 changed files with 10 additions and 10 deletions

View File

@ -101,17 +101,17 @@ export class AlipayProvider {
code: authCode,
});
const resp = result['alipay_system_oauth_token_response'];
const resp = result['alipay_system_oauth_token_response'] as Record<string, unknown> | undefined;
if (!resp || result['error_response']) {
const err = result['error_response'] || {};
const err = (result['error_response'] || {}) as Record<string, unknown>;
this.logger.error(`Alipay token exchange failed: ${JSON.stringify(err)}`);
throw new BadRequestException(
`支付宝授权失败: ${err.sub_msg || err.msg || '未知错误'} (code: ${err.code || '?'})`,
`支付宝授权失败: ${err['sub_msg'] || err['msg'] || '未知错误'} (code: ${err['code'] || '?'})`,
);
}
this.logger.log(`Alipay token exchanged: userId=${resp.user_id}`);
return resp as AlipayTokenResponse;
this.logger.log(`Alipay token exchanged: userId=${resp['user_id']}`);
return resp as unknown as AlipayTokenResponse;
}
/**
@ -126,16 +126,16 @@ export class AlipayProvider {
accessToken,
);
const resp = result['alipay_user_info_share_response'];
if (!resp || result['error_response'] || resp.code !== '10000') {
const err = result['error_response'] || resp || {};
const resp = result['alipay_user_info_share_response'] as Record<string, unknown> | undefined;
if (!resp || result['error_response'] || resp['code'] !== '10000') {
const err = (result['error_response'] || resp || {}) as Record<string, unknown>;
this.logger.error(`Alipay userinfo failed: ${JSON.stringify(err)}`);
throw new BadRequestException(
`获取支付宝用户信息失败: ${err.sub_msg || err.msg || '请确认已开通「获取会员信息」接口权限'}`,
`获取支付宝用户信息失败: ${err['sub_msg'] || err['msg'] || '请确认已开通「获取会员信息」接口权限'}`,
);
}
return resp as AlipayUserInfo;
return resp as unknown as AlipayUserInfo;
}
/**