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:
parent
bbaa5bf221
commit
b7aa0bf27b
2 changed files with 19 additions and 6 deletions
|
|
@ -161,7 +161,9 @@ export class RateLimitError extends ApiError {
|
||||||
|
|
||||||
super('RATE_LIMITED', 429, message, details)
|
super('RATE_LIMITED', 429, message, details)
|
||||||
this.name = 'RateLimitError' as any
|
this.name = 'RateLimitError' as any
|
||||||
this.retryAfter = retryAfter
|
if (retryAfter !== undefined) {
|
||||||
|
this.retryAfter = retryAfter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,14 +53,25 @@ export class UserAdapter extends BaseAdapter {
|
||||||
|
|
||||||
const items = Array.isArray(response.profile?.parties) ? response.profile.parties : []
|
const items = Array.isArray(response.profile?.parties) ? response.profile.parties : []
|
||||||
|
|
||||||
return {
|
const result: UserProfileResponse = {
|
||||||
user: response.profile,
|
user: response.profile,
|
||||||
items,
|
items,
|
||||||
page,
|
page
|
||||||
total: response.meta?.count,
|
|
||||||
totalPages: response.meta?.total_pages || response.meta?.totalPages,
|
|
||||||
perPage: response.meta?.per_page || response.meta?.perPage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue