Hi,
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(game.GetService)
The problem with this is that it just isn’t nice to look at, especially when/if I need to use colon syntax, I would need to do something like:
local t = ()
t.func = function(self, arg1, arg2)
end :: typeof(game.GetService)
instead of this, which is the desired syntax:
local t = {}
function t:func(arg1, arg2)
end :: typeof(game.GetService)
The problem is that the syntax I want to use, is not valid:
So, is there a way to assign a function’s type with using the desired syntax?
I’ve tried several different syntaxes, all of which are not valid:
function t:func()
end :: type
function t:func: type ()
end
I tried looking at the Luau language page as well as on the docs site to no avail. Any ideas?