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
I'm trying to type a generic state accessor where the return type depends on the key:
---@classFoo---@fieldcostnumber---@fieldnamestring---@typeFoolocalFooObj= {
cost=100,
name='example',
}
---@genericKextends keyof Foo---@paramkeyK---@returnFoo[K]functionget(key)
returnFooObj[key]
endlocalx=get('cost') -- hovering x should show: number, but shows: any
Is this a pattern supported by emmy lua, or am I missing feature that would allow me to do something like this ?
Activity
CppCXY commentedon Mar 16, 2026
The handling for the Foo[K] syntax has not been implemented yet.
sudo-tee commentedon Mar 16, 2026
Thanks seem to work great as an alternative for the moment.