Overload hook.Add
's eventName
with events defined in the wiki
#39
Labels
enhancement
New feature or request
hook.Add
's eventName
with events defined in the wiki
#39
I don't know how much this is needed, but I think that having this would be a huge help while programming.
The page for
hook.Add
describeseventName
like this:LuaLS allows to specify a string as its own separate type.
So, if we take the
GM:Move
hook as an example, thehook.Add
function can have an overload like:--- @overload fun(eventName: "Move", identifier: any, func: fun(ply: Player, mv: CMoveData): boolean?)
... which will then allow for this to happen:
ply
andmv
will also be of the right types already, though LuaLS will complain if nothing is returned here, which may not be wanted if, for example, the programmer wants to just inspectply
and/ormv
.This can be accounted for by having the return type be optional here (
boolean?
).Custom hooks should not be affected, as LuaLS will just use the original definition of the function, where
eventName
isstring
andfunc
is simplyfunction
.Adding
GM
hooks would be okay, but there's also the hooks described on the page forgameevent
, which would require more special treatment.The text was updated successfully, but these errors were encountered: