Closed uttk closed 2 months ago
4.4.12
Node.js
FormData values can contain arrays, but if you are using Honor RPC you will get a type error.
import { Hono } from "hono"; import { hc } from "hono/client"; import { validator } from "hono/validator"; const route = new Hono().post( "/", validator("form", (value: { body?: string[] }, c) => { const body = value["body"]; if (!body || !Array.isArray(body)) { return c.text("Invalid!", 400); } return { body }; }), (ctx) => { return ctx.text(`Body is [${ctx.req.valid("form").body}]`) } ); const client = hc<typeof route>(""); client.index.$post({ form: { body: ["1", "2", "3"], /*********** TYPE ERROR ! ***********/ }, });
Hono PRC allows you to specify the array.
client.index.$post({ form: { body: ["1", "2", "3"], // No type errors }, });
No response
Since "hono/client" allows you to specify an array, I guess the problem is only with type information.
"hono/client"
https://github.com/honojs/hono/blob/51264492269c0f842697736825e47903ae868bca/src/client/client.ts#L68-L80
Hi @uttk
Thank you for the issue. This is a bug. I'll fix it later.
Thank you! Hono is verrrrrrrrrrrrrrrry fast, but I was surprised at the author respond is verrrrrrrrrrrrrrrry fast😹
What version of Hono are you using?
4.4.12
What runtime/platform is your app running on?
Node.js
What steps can reproduce the bug?
FormData values can contain arrays, but if you are using Honor RPC you will get a type error.
What is the expected behavior?
Hono PRC allows you to specify the array.
What do you see instead?
No response
Additional information
Since
"hono/client"
allows you to specify an array, I guess the problem is only with type information.https://github.com/honojs/hono/blob/51264492269c0f842697736825e47903ae868bca/src/client/client.ts#L68-L80