-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
I'm trying to type a generic state accessor where the return type depends on the key:
---@class Foo
---@field cost number
---@field name string
---@type Foo
local FooObj = {
cost = 100,
name = 'example',
}
---@generic K extends keyof Foo
---@param key K
---@return Foo[K]
function get(key)
return FooObj[key]
end
local x = 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 ?
Thanks a lor for your help
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels