types: Types.object metatable reads typed any; lint baseline 91
This commit is contained in:
1 parent
6fab0d3dca
commit
d339f1e081
2 files changed
+7
-7
No files matched your search
@@ -656,20 +656,20 @@ Types.null = table.freeze(setmetatable({}, nullMeta))
|
|||||||
-- own) an entry in a weak map.
|
-- own) an entry in a weak map.
|
||||||
local objectMeta: { [any]: { any } } = setmetatable({}, { __mode = "k" }) :: any -- object -> its key order
|
local objectMeta: { [any]: { any } } = setmetatable({}, { __mode = "k" }) :: any -- object -> its key order
|
||||||
local function orderOf(v: any): { any }?
|
local function orderOf(v: any): { any }?
|
||||||
local mt = getmetatable(v)
|
local mt: any = getmetatable(v)
|
||||||
if type(mt) == "table" then
|
if type(mt) == "table" then
|
||||||
local k = rawget(mt, "__keys")
|
local k: any = rawget(mt, "__keys")
|
||||||
if k ~= nil then
|
if k ~= nil then
|
||||||
return k
|
return k
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return objectMeta[v]
|
return objectMeta[v]
|
||||||
end
|
end
|
||||||
local NOKEYS = table.freeze({})
|
local NOKEYS: { any } = table.freeze({}) :: any
|
||||||
function Types.object(t: { [any]: any }?, keys: { any }?): { [any]: any }
|
function Types.object(t: { [any]: any }?, keys: { any }?): { [any]: any }
|
||||||
local o: { [any]: any } = t or {}
|
local o: { [any]: any } = t or {}
|
||||||
local k = keys or NOKEYS
|
local k: { any } = keys or NOKEYS
|
||||||
local mt = getmetatable(o)
|
local mt: any = getmetatable(o)
|
||||||
if mt == nil or (type(mt) == "table" and rawget(mt, "__keys") ~= nil) then
|
if mt == nil or (type(mt) == "table" and rawget(mt, "__keys") ~= nil) then
|
||||||
setmetatable(o, { __object = true, __keys = k })
|
setmetatable(o, { __object = true, __keys = k })
|
||||||
else
|
else
|
||||||
@@ -684,7 +684,7 @@ function Types.set(o: { [any]: any }, k: any, v: any)
|
|||||||
local order = orderOf(o)
|
local order = orderOf(o)
|
||||||
if order and o[k] == nil and v ~= nil then
|
if order and o[k] == nil and v ~= nil then
|
||||||
if order == NOKEYS then
|
if order == NOKEYS then
|
||||||
local mt = getmetatable(o)
|
local mt: any = getmetatable(o)
|
||||||
if type(mt) == "table" and rawget(mt, "__keys") == NOKEYS then
|
if type(mt) == "table" and rawget(mt, "__keys") == NOKEYS then
|
||||||
mt.__keys = { k }
|
mt.__keys = { k }
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
92
|
91
|
||||||
Reference in new issue
Block a user