luau
luau copied to clipboard
[new solver] Refinement of generic key in table key assignment breaks
Using latest version of luau-lsp.
function tt.select<K, V>(t: { [K]: V }, columns: { K }): { [K]: V }
local result = {}
if tt.caniteratenormally(t) then
for k, v in t do
if table.find(columns, k) then
result[k] = v -- TypeError: Type function instance refine<intersect<K, ~nil>, *no-refine*> is uninhabited
end
end
else
for k, v in pairs(t) do
if table.find(columns, k) then
result[k] = v
end
end
end
return result
end