What version of Hono are you using?
4.11.1
What runtime/platform is your app running on? (with version if possible)
Bun
What steps can reproduce the bug?
const app = new Hono<AppEnv>()
const feedQueryParamsSchema = z.object({
userId: z.string().optional(),
remixId: z.string().optional(),
visibility: z.array(z.enum(['public', 'private', 'draft'])).optional(),
orderBy: z.enum(['published-at', 'updated-at', 'trending']).optional(),
cursor: z.string().optional(),
limit: z.coerce.number().min(1).max(100).optional().default(6),
})
const apps = app.get('/feed', zValidator('query', feedQueryParamsSchema), async (c) => {
const { cursor, limit } = c.req.valid('query')
return c.json({
data: [],
nextCursor: 'some-string',
})
})
export { apps }
export type AppsRoute = typeof apps
This resolves to
If I remove the .optional(), it works well
What is the expected behavior?
.optional() should not affect the type inference
What do you see instead?
I'm seeing fields being resolved to string | string [] | undefined, and not their actual type
Additional information
No response
What version of Hono are you using?
4.11.1
What runtime/platform is your app running on? (with version if possible)
Bun
What steps can reproduce the bug?
This resolves to
If I remove the
.optional(), it works wellWhat is the expected behavior?
.optional()should not affect the type inferenceWhat do you see instead?
I'm seeing fields being resolved to string | string [] | undefined, and not their actual type
Additional information
No response