Skip to content

Replace use state(null as t)#221

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
gloskull:Replace-useState(null-as-T)
Jun 29, 2026
Merged

Replace use state(null as t)#221
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
gloskull:Replace-useState(null-as-T)

Conversation

@gloskull

Copy link
Copy Markdown
Contributor

Motivation
Tighten loose typing on the API keys page by removing as casts and using proper generics so the file uses the shared apiClient typings and gains stronger type safety.
Description
Replace useState(null as ...) patterns with useState<... | null>(null) for items, created, error, and pendingRevoke in src/app/api-keys/page.tsx.
Use apiGet<{ items: KeyItem[] }> when loading the key list and apiPost<{ key: string }> when creating a key so the responses are properly typed and the as response casts are removed.
No changes to API paths, UI flows (reveal/copy/revoke), or runtime behaviour were made.
Testing
Ran npm run typecheck which passed with no type errors reported.
Ran the page-specific tests with npm test -- src/app/api-keys/page.test.tsx --runInBand which passed all tests (10/10).
Ran npm test -- --runInBand which surfaced unrelated existing test failures in other suites (usage page, ConfirmDialog, validateNumber, and KeyValueGrid).
Ran npm run lint and npm run build which failed due to pre-existing environment-related issues: lint errors in unrelated files and next/font failing to fetch Google Fonts in this environment respectively.
Closes #162

@gloskull

gloskull commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

** @mikewheeleer please merge.
If there are anymore tasks, even greater that 10 tasks please assign to me, i'd make sure to complete them in 2hours and submit PR**

@mikewheeleer

Copy link
Copy Markdown
Contributor

solid — in it goes 🚀

@mikewheeleer mikewheeleer merged commit 3901866 into Agentpay-Org:main Jun 29, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace useState(null as T) casts on the API keys page with typed generics

2 participants