luau
luau copied to clipboard
Using vararg generics to infer the arguments of a function will error if there are no arguments passed.
local signal = {}
signal.__index = signal
type InternalIdentity<T...> = setmetatable<{ (T...) -> () }, typeof(signal)>
local function constructor<T...>(): InternalIdentity<T...>
return setmetatable({}, signal)
end
function signal.fire<T...>(self: InternalIdentity<T...>, ...: T...): () end
constructor():fire()
This is probably generalization missing something.