فهرست منبع

📝 docs(rpc): add documentation for rpc type extraction

- document how to use InferResponseType to extract response types
- document how to use InferRequestType to extract request types
- provide typescript examples for rpc type safety implementation
yourname 4 ماه پیش
والد
کامیت
508c198c99
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      .roo/commands/rpc-type.md

+ 15 - 0
.roo/commands/rpc-type.md

@@ -0,0 +1,15 @@
+---
+description: "提取rpc响应,请求类型"
+---
+
+rpc类型安全
+示例:
+```typescript
+// 使用InferResponseType提取响应类型
+import type { InferResponseType } from 'hono/client'
+type LoginResponse = InferResponseType<typeof authClient['mini-login']['$post'], 200>
+
+// 使用InferRequestType提取请求类型
+import type { InferRequestType } from 'hono/client'
+type LoginRequest = InferRequestType<typeof authClient['mini-login']['$post']>['json']
+```