luau icon indicating copy to clipboard operation
luau copied to clipboard

Generic table types also lose their aliased/synthetic name

Open cheesycod opened this issue 9 months ago • 0 comments

Setup is:

File promise.luau:

--- Opaque promise type returned by antiraid
export type LuaPromise<T> = {
    --- Note: this will always actually be nil but is required to enforce nominal typing properly
    read __phantom: T,
}

--- Yields the coroutine and resumes it returning the end value of the promise when it resolves
local function yield<T>(promise: LuaPromise<T>): T 
    error("Implemented internally in AntiRaid runtime!")
end

return {
    yield = yield
}

File kv.luau:

--- KvExecutor allows templates to get, store and find persistent data within a server.
---@class KvExecutor
export type KvExecutor = {
    --- The guild ID the executor will perform key-value operations on.
    read guild_id: string,
    --- The originating guild ID (the guild ID of the template itself).
    read origin_guild_id: string,
    --- The scope of the executor.
    read scope: ExecutorScope.ExecutorScope,

    --- Finds records in the key-value store.
    --- @param query string The key to search for. % matches zero or more characters; _ matches a single character. To search anywhere in a string, surround {KEY} with %, e.g. %{KEY}%
    --- @return {KvRecord} The records.
    find: (self: KvExecutor, query: string) -> Promise.LuaPromise<{KvRecord}>,
    --- Gets a value from the key-value store.
    --- @param key string The key of the record.
    --- @return any The value of the record.
    get: (self: KvExecutor, key: string) -> Promise.LuaPromise<any>,
    --- Gets a record from the key-value store.
    --- @param key string The key of the record.
    --- @return KvRecord The record.
    getrecord: (self: KvExecutor, key: string) -> Promise.LuaPromise<KvRecord>,
    --- Sets a record in the key-value store.
    --- @param key string The key of the record.
    --- @param value any The value of the record.
    --- @return KvRecord The record.
    set: (self: KvExecutor, key: string, value: any) -> Promise.LuaPromise<KvRecord>,
    --- Deletes a record from the key-value store.
    --- @param key string The key of the record.
    delete: (self: KvExecutor, key: string) -> Promise.LuaPromise<nil>,
}

Now in a file once.luau do:

local hasRun = ge.kv:get("__once:" .. id)

Notice that hasRun loses its synthetic name

cheesycod avatar Mar 30 '25 18:03 cheesycod