Multiple-arity generic params
local type Error<TRet, TErr> = {TRet | nil, TErr}
local type Error<TRet> = Error<TRet, string>
local function divide(x: number, y: number): Error<number>
if y == 0 then return { nil, "Cannot divide by 0" } end
return x / y
end
This is how C# implements "varadict" generic params, and can help with a lot of patterns, i.e arbritary params on a func
Can it just be type ErrorStr<TRet> = Error<TRet, string>?
Can it just be
type ErrorStr<TRet> = Error<TRet, string>?
yes, but then you do not have any of the upsides of being able to have default type params
Teal only supports this kind of polymorphism in record fields coming from Lua APIs (i.e. for interoperability), and we don't support default arguments anywhere else.
I don't think the added complexity to the compiler is worth it. If the purpose is just to save a bit of typing, this kind of shorthand would probably be best served with a macro, in the future.