Hey, I noticed how in Studio autocomplete shows a description of a ModuleScript function
I’m assuming ‘[unknown]’ is supposed to show what it returns? If so, is there a way to put some commentation in front of the function to change ‘[unknown]’ to what it returns?
I don’t think there’s any way to annotate functions so that intellisense shows the return type you want. Unless the type of the return values are obvious just from looking at the code (e.g. return true
or local a = 1 return a
), it always shows up as [unknown]
from my testing. Even trying to do tonumber()
on a return value won’t force the function’s return type to be number
since tonumber
can return nil. It doesn’t handle branching either, even if both branches would return the same type.
Just wait until either analysis improves or until typed Lua comes out…
EDIT: I found a way for number
and string
, but it’s messy and stupid. If you want to force the return type to be a number
, you can do return math.max(yourNumberHere, -math.huge)
. If you want to force it to be a string
, you can do return string.format(yourstringhere)
.