Skip to content
Myr

fix(type): check 1st arg of middleware is `string` (#1470)

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

* fix(type): check 1st arg of middleware is `string` * denoify

authored by Yusuke Wada · committed by GitHub · parent bb386a4 · Browse files · 3 files+27 added−11 removed
This commit

State

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

Diff stats

3 files+27 added−11 removed

  • tests:+15 added−1 removed
  • other:+12 added−10 removed

3 files+27 added−11 removed

modified:deno_dist/types.ts+6 added-5 removed
40 unmodified lines
41 I extends Input = Input,42 R extends HandlerResponse<any> = any43> = (c: Context<E, P, I>, next: Next) => R4445export type MiddlewareHandler<E extends Env = any, P extends string = any, I extends Input = {}> = (46 c: Context<E, P, I>,47 next: Next48) => Promise<Response | void>45export type MiddlewareHandler<46 E extends Env = any,47 P extends string = string,48 I extends Input = {}49> = (c: Context<E, P, I>, next: Next) => Promise<Response | void>5051export type H<52 E extends Env = any,53 P extends string = any,
14 unmodified lines
68////////////////////////////////////////6970export interface HandlerInterface<71 E extends Env = Env,71 M extends string = any,72 M extends string = string,73 S extends Schema = {},74 BasePath extends string = '/'75> {76 //// app.get(...handlers[])
488 unmodified lines
modified:src/hono.test.ts+15 added-1 removed
2486 unmodified lines
2487 c.var.echo('hello') + c.var.echo2('hello2') + c.var.echo3('hello3') + c.var.echo4('hello4')2488 )2489 })24902491 // @ts-expect-error2492 app.use('/no-path/5').get(mw(), mw2(), mw3(), mw4(), mw5(), (c) => {2493 return c.text(2493 // @ts-ignore2494 // @ts-expect-error2495 c.var.echo('hello') +2496 // @ts-expect-error2497 c.var.echo2('hello2') +2498 // @ts-expect-error2499 c.var.echo3('hello3') +2500 // @ts-expect-error2501 c.var.echo4('hello4') +2502 // @ts-expect-error2503 c.var.echo5('hello5')2504 )2505 })2506
182 unmodified lines
26892690 app.use(mw())2691 app.use('*', mw())2692 })26932694 it('Should throw type errors', (c) => {2695 try {2696 // @ts-expect-error2697 app.get(['foo', 'bar'], poweredBy())2698 // @ts-expect-error2699 app.use(['foo', 'bar'], poweredBy())2700 } catch {}2701 })2702})
modified:src/types.ts+6 added-5 removed
40 unmodified lines
41 I extends Input = Input,42 R extends HandlerResponse<any> = any43> = (c: Context<E, P, I>, next: Next) => R4445export type MiddlewareHandler<E extends Env = any, P extends string = any, I extends Input = {}> = (46 c: Context<E, P, I>,47 next: Next48) => Promise<Response | void>45export type MiddlewareHandler<46 E extends Env = any,47 P extends string = string,48 I extends Input = {}49> = (c: Context<E, P, I>, next: Next) => Promise<Response | void>5051export type H<52 E extends Env = any,53 P extends string = any,
14 unmodified lines
68////////////////////////////////////////6970export interface HandlerInterface<71 E extends Env = Env,71 M extends string = any,72 M extends string = string,73 S extends Schema = {},74 BasePath extends string = '/'75> {76 //// app.get(...handlers[])
488 unmodified lines