fix: handle optional properties with exactOptionalPropertyTypes

- errors.ts: Only assign retryAfter when defined, not undefined
- user.adapter.ts: Build UserProfileResponse conditionally
  - Only include optional properties (total, totalPages, perPage) when defined
  - Use intermediate variables to ensure type safety

Fixes exactOptionalPropertyTypes violations where `T | undefined` cannot be
assigned to optional property `prop?: T`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-11-28 18:17:01 -08:00
parent bbaa5bf221
commit b7aa0bf27b
2 changed files with 19 additions and 6 deletions

View file

@ -161,7 +161,9 @@ export class RateLimitError extends ApiError {
super('RATE_LIMITED', 429, message, details)
this.name = 'RateLimitError' as any
this.retryAfter = retryAfter
if (retryAfter !== undefined) {
this.retryAfter = retryAfter
}
}
}

View file

@ -53,14 +53,25 @@ export class UserAdapter extends BaseAdapter {
const items = Array.isArray(response.profile?.parties) ? response.profile.parties : []
return {
const result: UserProfileResponse = {
user: response.profile,
items,
page,
total: response.meta?.count,
totalPages: response.meta?.total_pages || response.meta?.totalPages,
perPage: response.meta?.per_page || response.meta?.perPage
page
}
if (response.meta?.count !== undefined) {
result.total = response.meta.count
}
const totalPages = response.meta?.total_pages ?? response.meta?.totalPages
if (totalPages !== undefined) {
result.totalPages = totalPages
}
const perPage = response.meta?.per_page ?? response.meta?.perPage
if (perPage !== undefined) {
result.perPage = perPage
}
return result
}
/**