I have been experimenting with typechecking lately. But the problem is that I am making a module with functions like this function module:randomFunction() but I dont know how to make them work with typechecking as if I try to call module:randomFunction() it would error. How would I fix this?
For typechecking functions, you need to include a return type. e.g.
function module:randomFunction(): any
end
Sorry if you understood me incorrectly.
I meant if you created a type. Then assigned it to a table and tried calling function module:randomFunction() it would result in a error.
type moduleTypeCheck = {
randomFunction: () -> () -- Trying to call module:randomFunction would result in a error
}
local module = {}
function module:randomFunction()
end
return module
It doesn’t look like you have assigned the type, from the looks of it. Also I’m fairly sure that function typecheck isn’t complete?