Replace use state(null as t)#221
Merged
mikewheeleer merged 2 commits intoJun 29, 2026
Merged
Conversation
…afety refactor(api-keys): use typed apiClient generics
Contributor
Author
|
** @mikewheeleer please merge. |
Contributor
|
solid — in it goes 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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