You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Elysia } from 'elysia'
const setup = new Elysia({ name: 'setup' }
.decorate(() => {
return { user: 'user' };
})
const main = new Elysia()
.use(setup)
.get('/', ({ user }) => user);
But using derive or resolve instead of decorate will not work:
import { Elysia } from 'elysia'
const setup = new Elysia({ name: 'setup' })
.resolve(() => { // same happens with derive
return { user: 'user' };
})
const main = new Elysia()
.use(setup)
.get('/', ({ user }) => user); // TS2339: Property user does not exist on type ...
Is it not possible to encapsulate resolve/derive logic into plugins while maintaining type inference? Is this a bug or limitation of Elysia?
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered:
What version of Elysia.JS is running?
1.0.9
What platform is your computer?
Darwin 22.5.0 x86_64 i386
What steps can reproduce the bug?
The docs introduce a service locator pattern in order to correctly use decorated values in other instances (https://elysiajs.com/essential/plugin.html#service-locator).
This works:
But using derive or resolve instead of decorate will not work:
Is it not possible to encapsulate resolve/derive logic into plugins while maintaining type inference? Is this a bug or limitation of Elysia?
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: