Skip to content

regression in Context/c.json() type inference in v4.9.8 #4427

@sigmachirality

Description

@sigmachirality

What version of Hono are you using?

4.9.8

What runtime/platform is your app running on? (with version if possible)

Bun (1.2.16), TypeScript (^5.8.2)

What steps can reproduce the bug?

import type { Context } from "hono";

export function test(c: Context) {
  return c.json("test", 200);
}

What is the expected behavior?

For this to typecheck/for TS language server to be able to infer the returned type without annotation here.

What do you see instead?

In 4.9.8, this gives the following type error:

The inferred type of 'test' cannot be named without a reference to '../../../../node_modules/hono/dist/types/context'. This is likely not portable. A type annotation is necessary.ts(2742)

Additional information

Reverting to 4.9.7 allows the TS language server to infer the returned type correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions