honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
20.18k stars 576 forks source link

4.4.12 breaks client typing when using use with a path #3122

Closed BryanAbate closed 3 months ago

BryanAbate commented 4 months ago

What version of Hono are you using?

4.4.12

What runtime/platform is your app running on?

Node

What steps can reproduce the bug?

Stackblitz of the reproduction: https://stackblitz.com/edit/hono-client-typing-issue-middleware?file=src%2Fapp.ts

When using .use with a path like .use('*', myMiddleware) hono client typings will break. Removing the path '*' solves the typing issue.

I suppose https://github.com/honojs/hono/pull/3087 introduced the regression.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

EdamAme-x commented 3 months ago

.use always generate { [x: string]: never } image

EdamAme-x commented 3 months ago

It may be cause https://github.com/honojs/hono/blob/main/src/types.ts#L1806

EdamAme-x commented 3 months ago

generics of .use was marked at any image

EdamAme-x commented 3 months ago

createMiddleware breaks typing image

EdamAme-x commented 3 months ago

I will try to work on this issue. https://github.com/honojs/hono/blob/main/src/types.ts#L680

EdamAme-x commented 3 months ago

This is a common workaround, but I don't think it is what you are looking for. image

BryanAbate commented 3 months ago

Thank you for looking into the issue @EdamAme-x !