luau icon indicating copy to clipboard operation
luau copied to clipboard

Using vararg generics to infer the arguments of a function will error if there are no arguments passed.

Open ffrostfall opened this issue 10 months ago • 1 comments

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()

Image

ffrostfall avatar Feb 19 '25 23:02 ffrostfall

This is probably generalization missing something.

aatxe avatar Feb 19 '25 23:02 aatxe