Properly type EmptyQuery

This commit is contained in:
Ukendio 2024-07-14 08:30:20 +02:00
parent 150afc46e4
commit 48cc4dc7d5

View file

@ -662,31 +662,43 @@ local function world_get(world: World, entityId: i53, a: i53, b: i53?, c: i53?,
end end
end end
local function noop() type Item = () -> (number, ...any)
return nil export type Query = typeof({
__iter = function(): Item
return function()
return 1
end
end,
}) & {
next: Item,
replace: (Query, ...any) -> (),
without: (Query) -> Query
}
type CompatibleArchetype = { archetype: Archetype, indices: { number } }
local world_query: (World, ...i53) -> Query
do
local noop: Item = function()
return nil :: any
end end
local EmptyQuery = { local EmptyQuery: Query = {
__iter = function() __iter = function(): Item
return noop return function()
return 1
end
end, end,
next = noop, next = noop :: Item,
replace = noop, replace = noop :: (Query, ...any) -> (),
without = function(self) without = function(self: Query, ...)
return self return self
end end
} }
setmetatable(EmptyQuery, EmptyQuery) setmetatable(EmptyQuery, EmptyQuery)
export type Query = typeof(EmptyQuery)
type CompatibleArchetype = { archetype: Archetype, indices: { number } }
local world_query: (World, ...i53) -> Query
do
local indices: { { number } } local indices: { { number } }
local compatibleArchetypes: { Archetype } local compatibleArchetypes: { Archetype }
local length local length