-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
Problem
Mapped types like Pick<T, K> show errors and don't resolve fields correctly for direct access.
Reproduction
---@alias Pick<T, K extends keyof T> { [P in K]: T[P]; }
---@param v {name: string, age: number}
local function use_person(v)
print(v.name) -- Field access works inside function
print(v.age)
end
---@type Pick<{name: string, age: number, email: string}, "name" | "age">
local picked
use_person(picked) -- No error here (type compatibility works)
print(picked.name) -- ERROR: Undefined field `name`Observed Behavior
[type-not-found]Type 'T' not founderror on the@alias Pick<T, K extends keyof T>line[undefined-field]Undefined field 'name'when accessingpicked.namedirectly- Type compatibility for function parameters appears to work (no error on
use_person(picked))
Expected Behavior
- No "Type T not found" error on the alias definition
- Field access on mapped type variables should resolve correctly (e.g.,
picked.nameshould bestring)
Environment
- emmylua_ls version: 0.19.0
- Editor: Neovim
Notes
The unit tests in generic_test.rs (test_type_mapped_pick, test_type_partial) only verify type compatibility via function parameters, not direct field access. This may explain why the feature appears to work in tests but not in practice.
Metadata
Metadata
Assignees
Labels
No labels