From b23cf8d65d851de9726d6388b45dda39e6fdb9ab Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 25 Jan 2024 21:38:21 +0900 Subject: [PATCH] fix(factory): correct types inside of `createMiddleware()` (#2081) * fix(factory): correct types inside of `createMiddleware()` * denoify --- deno_dist/helper/factory/index.ts | 2 +- src/helper/factory/index.test.ts | 3 ++- src/helper/factory/index.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/deno_dist/helper/factory/index.ts b/deno_dist/helper/factory/index.ts index 93b13e267..91290f88b 100644 --- a/deno_dist/helper/factory/index.ts +++ b/deno_dist/helper/factory/index.ts @@ -270,5 +270,5 @@ export class Factory { export const createFactory = () => new Factory() export const createMiddleware = ( - middleware: MiddlewareHandler + middleware: MiddlewareHandler ) => createFactory().createMiddleware(middleware) diff --git a/src/helper/factory/index.test.ts b/src/helper/factory/index.test.ts index eaf390ff5..fb7c661b2 100644 --- a/src/helper/factory/index.test.ts +++ b/src/helper/factory/index.test.ts @@ -8,10 +8,11 @@ import { createMiddleware, createFactory } from './index' describe('createMiddleware', () => { type Env = { Variables: { foo: string } } - const app = new Hono() + const app = new Hono() const mw = (message: string) => createMiddleware(async (c, next) => { + expectTypeOf(c.var.foo).toEqualTypeOf() c.set('foo', 'bar') await next() c.header('X-Message', message) diff --git a/src/helper/factory/index.ts b/src/helper/factory/index.ts index 184870770..4c63c76eb 100644 --- a/src/helper/factory/index.ts +++ b/src/helper/factory/index.ts @@ -270,5 +270,5 @@ export class Factory { export const createFactory = () => new Factory() export const createMiddleware = ( - middleware: MiddlewareHandler + middleware: MiddlewareHandler ) => createFactory().createMiddleware(middleware)