Skip to content

Add explicit return type annotation to useApiClient hook#1268

Draft
Lang-Qiu wants to merge 1 commit into
joinmarket-webui:develfrom
Lang-Qiu:auto-pr/type_annotations-1780770490
Draft

Add explicit return type annotation to useApiClient hook#1268
Lang-Qiu wants to merge 1 commit into
joinmarket-webui:develfrom
Lang-Qiu:auto-pr/type_annotations-1780770490

Conversation

@Lang-Qiu

@Lang-Qiu Lang-Qiu commented Jun 6, 2026

Copy link
Copy Markdown

问题背景

useApiClient 函数在 src/hooks/useApiClient.ts 中缺少显式返回类型注解。虽然 TypeScript 能够推断类型,但显式注解能提高代码的可读性和维护性,使函数签名更清晰,便于未来扩展和调试。

修改内容

  • useApiClient 函数添加了显式返回类型注解 () => ReturnType<typeof createApiClient>,明确指定了返回类型与 createApiClient 函数保持一致。
  • 优化了代码格式,移除了不必要的空行,使代码更简洁。

验证方式

  • 运行 TypeScript 类型检查(例如 tsc --noEmit)确保没有引入类型错误。
  • 执行现有测试套件,验证功能行为未发生变化。
  • 检查代码可读性,确认注解增强了类型安全性。

@theborakompanioni

Copy link
Copy Markdown
Collaborator

Hey @Lang-Qiu - I see this is still a draft? If you run npm run format once and push it, I'd merge it 🚀

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.

3 participants