Page 1 of 1

Use overload signatures where possible instead of union return types

Posted: Thu Nov 07, 2024 7:49 pm
by justarandomgeek
for example, https://lua-api.factorio.com/latest/cla ... stic_point could trivially be a function with two overloads: fun():LuaLogisticPoint, fun(index):dictionary, and we could in turn generate overload tags for LuaLS to correctly determine which return it got from a given call by the arguments. there are many other functions like this where the return type depends only on the argument types for which function overloads are a *perfect* fit.

This would also help in many cases where the type of later arguments depend on the type (or enum value) of earlier arguments.

Re: Use overload signatures where possible instead of union return types

Posted: Thu Nov 07, 2024 9:37 pm
by curiosity
Dealing with uncertain return types is a bother. This would be great to have.