The following code only throws the type error "setmetatable should take a table", only when the export variable is not annotated
or tbl in the setmetatable is cast to any
local mt = {
bar = function(self: any)
end
}
mt.__index = mt
local tbl = {
foo = 1
}
-- perfectly fine
local export = setmetatable(tbl, mt)
-- setmetatable should take a table
local export: typeof(setmetatable(tbl, mt)) = setmetatable(tbl, mt)
-- fine again
local export: typeof(setmetatable(tbl, mt)) = setmetatable(tbl :: any, mt)
The following code only throws the type error "setmetatable should take a table", only when the export variable is not annotated or tbl in the setmetatable is cast to any