You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if it's possible to assign a function's type when the function is a member of a table using function:method() syntax?
Basically, from what I know, the only way to assign a function's type when the function is a member of a table is the following:
local t = {}
t.func = function()
end :: typeof(otherFunc)
The problem with this is that it just isn't nice to look at, especially when/if I need to use a colon to call the function, I would need to do something like:
local t = ()
t.func = function(self, arg1, arg2)
end :: typeof(otherFunc)
instead of this, which is the desired syntax, but it is not valid:
local t = {}
function t:func(arg1, arg2)
end :: typeof(otherFunc)
So, is there a way to assign a function's type with using the desired function table:method() syntax?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm wondering if it's possible to assign a function's type when the function is a member of a table using
function:method()
syntax?Basically, from what I know, the only way to assign a function's type when the function is a member of a table is the following:
The problem with this is that it just isn't nice to look at, especially when/if I need to use a colon to call the function, I would need to do something like:
instead of this, which is the desired syntax, but it is not valid:
So, is there a way to assign a function's type with using the desired
function table:method()
syntax?Beta Was this translation helpful? Give feedback.
All reactions