Skip to content
Myr

fix(types): correct `app.on(method,path[],middleware,handler)` type (#3802)

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

authored by Yusuke Wada · committed by GitHub · parent 5af7b4f · Browse files · 2 files+10 added−2 removed
This commit

State

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

Diff stats

2 files+10 added−2 removed

  • tests:+8 added−0 removed
  • other:+2 added−2 removed

2 files+10 added−2 removed

modified:src/types.test.ts+8 added
275 unmodified lines
276 }277 }278 type verify = Expect<Equal<Expected, Actual>>279 })280281 test('app.on(method, path[], middleware, handler) should not throw a type error', () => {282 const middleware: MiddlewareHandler<{ Variables: { foo: string } }> = async () => {}283 app.on('GET', ['/a', '/b'], middleware, (c) => {284 expectTypeOf(c.var.foo).toEqualTypeOf<string>()285 return c.json({})286 })287 })288})289290describe('TypedResponse', () => {291 test('unknown', () => {
2065 unmodified lines
modified:src/types.ts+2 added-2 removed
1743 unmodified lines
1744 ...handlers: H<E, MergePath<BasePath, P>, I, R>[]1745 ): HonoBase<E, S & ToSchema<string, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>17461747 // app.on(method | method[], path[], ...handlers[])1748 <I extends Input = BlankInput, R extends HandlerResponse<any> = any>(1748 <I extends Input = BlankInput, R extends HandlerResponse<any> = any, E2 extends Env = E>(1749 methods: string | string[],1750 paths: string[],1751 ...handlers: H<E, any, I, R>[]1751 ...handlers: H<E2, any, I, R>[]1752 ): HonoBase<E, S & ToSchema<string, string, I, MergeTypedResponse<R>>, BasePath>1753}17541755type ExtractStringKey<S> = keyof S & string
248 unmodified lines