0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

fix(types): broken test in future versions of typescript (#3310)

This commit is contained in:
m-shaka 2024-08-25 15:55:37 +09:00 committed by GitHub
parent d1c7f6f5f1
commit 6d7565e2a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2249,15 +2249,18 @@ describe('Returning type from `app.use(path, mw)`', () => {
})
})
describe('generic typed variables', () => {
const okHelper = (c: Context) => {
return <TData>(data: TData) => c.json({ data })
}
type Variables = {
ok: <TData>(data: TData) => TypedResponse<{ data: TData }>
ok: ReturnType<typeof okHelper>
}
const app = new Hono<{ Variables: Variables }>()
it('Should set and get variables with correct types', async () => {
const route = app
.use('*', async (c, next) => {
c.set('ok', (data) => c.json({ data }))
c.set('ok', okHelper(c))
await next()
})
.get('/', (c) => {