Closed bogeychan closed 1 month ago
1.0.22
WSL Ubuntu
import { Elysia, type Context } from 'elysia' const checker = { check: async (ctx: Context, name: string, state?: string) => { return typeof state !== 'undefined' } } new Elysia() .derive((ctx) => { const { name } = ctx.params return { check: async () => { const { state } = ctx.query if (!(await checker.check(ctx, name, state ?? ctx.query.state))) { throw new Error('State mismatch') } } } }) .get('/:name', async (ctx) => { await ctx.check() return 'yay' }) .listen(8080)
Open http://localhost:8080/yay?state=123
Respond with yay (no error thrown)
yay
{"name":"Error","message":"State mismatch"}
AOT does not recognize:
const { state } = ctx.query
ctx.query.state
undefined ?? ctx.query.state
const { query: { state } } = ctx
only this seems to work:
const state = ctx.query.state
const { state } = ctx.query and const { query: { state } } = ctx used to work back in 1.0.3:
1.0.3
346134b published under 1.0.23, including test case. Let me know if it works on your end.
Works for me, thnx
What version of Elysia.JS is running?
1.0.22
What platform is your computer?
WSL Ubuntu
What steps can reproduce the bug?
Open http://localhost:8080/yay?state=123
What is the expected behavior?
Respond with
yay
(no error thrown)What do you see instead?
Additional information
AOT does not recognize:
const { state } = ctx.query
ctx.query.state
undefined ?? ctx.query.state
const { query: { state } } = ctx
only this seems to work:
const state = ctx.query.state
const { state } = ctx.query
andconst { query: { state } } = ctx
used to work back in1.0.3
: