Skip to content
Myr

fix(client): exclude $all from ClientRequest type (#4611)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(client): exclude $all from ClientRequest type (#3184) The RPC client was incorrectly exposing `$all` as a valid method when using `app.all()`. Since HTTP has no "ALL" method, the client should not expose `$all` - users should use specific HTTP methods like `$get`, `$post`, etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * ci: apply automated fixes * fix(client): expand $all to standard HTTP methods in ClientRequest type Previously, routes defined with app.all() only excluded $all from the client type but didn't expose standard HTTP methods like $get, $post. This caused a mismatch where runtime behavior worked but types didn't. Now $all is expanded to all standard HTTP methods ($get, $post, $put, $delete, $options, $patch), matching the actual runtime behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * ci: apply automated fixes ---------

authored by Ryota Ikezawa · committed by GitHub · parent 28452f0 · Browse files · 2 files+63 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
  • Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

Diff stats

2 files+63 added−3 removed

  • tests:+33 added−0 removed
  • other:+30 added−3 removed

2 files+63 added−3 removed

modified:src/client/types.test.ts+33 added
modified:src/client/types.ts+30 added-3 removed
1import type { Hono } from '../hono'2import type { HonoBase } from '../hono-base'3import type { METHODS, METHOD_NAME_ALL_LOWERCASE } from '../router'4import type { Endpoint, ResponseFormat, Schema } from '../types'5import type { StatusCode, SuccessStatusCode } from '../utils/http-status'6import type { HasRequiredKeys } from '../utils/types'78/**9 * Type representing the '$all' method name10 */11type MethodNameAll = `$${typeof METHOD_NAME_ALL_LOWERCASE}`1213/**14 * Type representing all standard HTTP methods prefixed with '$'15 * e.g., '$get' | '$post' | '$put' | '$delete' | '$options' | '$patch'16 */17type StandardMethods = `$${(typeof METHODS)[number]}`1819/**20 * Expands '$all' into all standard HTTP methods.21 * If the schema contains '$all', it creates a type where all standard HTTP methods22 * point to the same endpoint definition as '$all', while removing '$all' itself.23 */24type ExpandAllMethod<S> = MethodNameAll extends keyof S25 ? { [M in StandardMethods]: S[MethodNameAll] } & Omit<S, MethodNameAll>26 : S2728type HonoRequest = (typeof Hono.prototype)['request']2930export type BuildSearchParamsFn = (query: Record<string, string | string[]>) => URLSearchParams31
32 unmodified lines
64 headers: T | (() => T | Promise<T>)65 })6667export type ClientRequest<Prefix extends string, Path extends string, S extends Schema> = {47 [M in keyof S]: S[M] extends Endpoint & { input: infer R }68 [M in keyof ExpandAllMethod<S>]: ExpandAllMethod<S>[M] extends Endpoint & { input: infer R }69 ? R extends object70 ? HasRequiredKeys<R> extends true50 ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>>51 : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>>71 ? (72 args: R,73 options?: ClientRequestOptions74 ) => Promise<ClientResponseOfEndpoint<ExpandAllMethod<S>[M]>>75 : (76 args?: R,77 options?: ClientRequestOptions78 ) => Promise<ClientResponseOfEndpoint<ExpandAllMethod<S>[M]>>79 : never80 : never81} & {82 $url: <
229 unmodified lines