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:
parent
d1c7f6f5f1
commit
6d7565e2a1
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user