Variadic Arguments Incompatible with Variadic Generic Type

More like a feature request

This is a case that the Luau compiler still can’t handle. I think it’s a tough one to solve, even with type functions, since you’re trying to create a method dynamically. but that’s just my opinion.

What you can do is define Example before using it. You could use overloading for that:

--!strict
type Example<T...> = {
	Method: (T...) -> ();
}
type SpecificExample = 
	Example<string> 
	& Example<number,string>
	-- & ...
	--list of all possible Examples
local function CreateExample(Method: any): SpecificExample
	local self = {}
	self.Method = Method
	return self
end
local Object: Example<string> = CreateExample(function(a: string)
	print(a)
end)
Object.Method("Hello World!")
1 Like