Narrow aabb types and give generic aliases their type argument

The aabb functions all index the named members, so passing the
shorthand [MapPosition, MapPosition] form would error at runtime. The
annotations now say so.

emmylua requires a type argument on a generic alias, luals did not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-07 15:31:18 +00:00
co-authored by Claude Opus 5
parent 90f32699c7
commit b9cfbc9036
6 changed files with 48 additions and 43 deletions
+15 -15
View File
@@ -94,7 +94,7 @@ Async.status = {}
--- @class Async.AsyncFunction
--- @field id number The id of this async function
--- @operator call: Async.AsyncReturn
--- @operator call: Async.AsyncReturn<any>
Async._function_prototype = {}
Async._function_metatable = {
@@ -123,20 +123,20 @@ script.register_metatable("AsyncReturn", Async._return_metatable)
--- Storage Variables
local resolve_next --- @type Async.AsyncReturn[] Stores a queue of async functions to be executed on the next tick
local resolve_queue --- @type Async.AsyncReturn[] Stores a queue of async functions to be executed on a later tick
local resolve_next --- @type Async.AsyncReturn<any>[] Stores a queue of async functions to be executed on the next tick
local resolve_queue --- @type Async.AsyncReturn<any>[] Stores a queue of async functions to be executed on a later tick
--- Insert an item into the priority queue
--- @param pending Async.AsyncReturn
--- @return Async.AsyncReturn
--- @param pending Async.AsyncReturn<any>
--- @return Async.AsyncReturn<any>
local function add_to_next_tick(pending)
resolve_next[#resolve_next + 1] = pending
return pending
end
--- Insert an item into the priority queue
--- @param pending Async.AsyncReturn
--- @return Async.AsyncReturn
--- @param pending Async.AsyncReturn<any>
--- @return Async.AsyncReturn<any>
local function add_to_resolve_queue(pending)
local tick = pending.tick
for index = #resolve_queue, 1, -1 do
@@ -191,7 +191,7 @@ end
--- Run an async function on the next tick, this is the default and can be used to bypass permission groups
--- @param ... any The arguments to call the function with
--- @return Async.AsyncReturn
--- @return Async.AsyncReturn<any>
function Async._function_prototype:start_soon(...)
assert(Async._registered[self.id], "Async function is not registered")
Async._queue_pressure[self.id] = Async._queue_pressure[self.id] + 1
@@ -204,7 +204,7 @@ end
--- Run an async function after the given number of ticks
--- @param ticks number The number of ticks to call the function after
--- @param ... any The arguments to call the function with
--- @return Async.AsyncReturn
--- @return Async.AsyncReturn<any>
function Async._function_prototype:start_after(ticks, ...)
ExpUtil.assert_argument_type(ticks, "number", 1, "ticks")
assert(ticks > 0, "Ticks must be a positive number")
@@ -219,7 +219,7 @@ end
--- Run an async function on the next tick if the function is not already queued, allows singleton task/thread behaviour
--- @param ... any The arguments to call the function with
--- @return Async.AsyncReturn | nil
--- @return Async.AsyncReturn<any> | nil
function Async._function_prototype:start_task(...)
assert(Async._registered[self.id], "Async function is not registered")
if Async._queue_pressure[self.id] > 0 then return end
@@ -228,7 +228,7 @@ end
--- Run an async function on this tick, then queue it based on its return value
--- @param ... any The arguments to call the function with
--- @return Async.AsyncReturn
--- @return Async.AsyncReturn<any>
function Async._function_prototype:start_now(...)
assert(Async._registered[self.id], "Async function is not registered")
local status, rtn1, rtn2 = Async._registered[self.id](...)
@@ -293,11 +293,11 @@ end
--- Status Returns.
--- @type Async.AsyncReturn[], Async.AsyncReturn[]
--- @type Async.AsyncReturn<any>[], Async.AsyncReturn<any>[]
local new_next, new_queue = {}, {} -- File scope to allow for reuse
--- Executes an async function and processes the return value
--- @param pending Async.AsyncReturn
--- @param pending Async.AsyncReturn<any>
--- @param tick number
local function exec(pending, tick)
local async_func = Async._registered[pending.func_id]
@@ -397,9 +397,9 @@ end
--- @package
function Async.on_init()
if storage.exp_async_next == nil then
--- @type Async.AsyncReturn[]
--- @type Async.AsyncReturn<any>[]
storage.exp_async_next = {}
--- @type Async.AsyncReturn[]
--- @type Async.AsyncReturn<any>[]
storage.exp_async_queue = {}
end
Async.on_load()