Add tooltip support for functions defined via typing

I find myself creating documentation on the types themselves rather than defining them on the actual implementation. This keeps types organized from code, and is much easier to read at a glance (since types are packed tightly together) than the actual implementation (spans hundreds of lines! Hard to scroll through).

Unfortunately… there is no support for documentation tooltips when function comments are defined within types:

someTab.hello does not fill in with the documentation “some docs”.

Without the type, we can do something like:

… which has the comment during autofill.

Solution: add function documentation support when documentation is applied via typing.

7 Likes

This would be especially useful because having a table be casted as a type breaks the ability to apply any doc comments to its functions whatsoever. For example:

type Library = {
	DoSomething: () -> ()
}

local Library = {} :: Library

--[[
	NEVER CALL THIS FUNCTION!!!
]]
function Library.DoSomething()
	print("Commencing destruction sequence...")
	DestroyTheUniverse()
end

return Library

Now whenever I look at the code completion, I only see this:
image

1 Like

Well, to ask a question. Assuming I defined a tooltip comment in the type definition and then we further defined one in the concrete function implementation, would the concrete function implementation override the type definition tooltip?

Also I do agree this is a good addition. We could have something similar to interfaces/virtuals in other languages, without the actual function definition of course

1 Like

This would be very helpful

In the meantime, theres technically a “workaround”

type someType = {
	--[[
		some docs
	]]
	hello: typeof(function() end)
}

should provide the hello function with the documentation tooltip if I my memory doesn’t fail me

Oh wait I found the post for the workaround

1 Like

I have tendency of making a module specifically for types, which appear in two or more scripts/modules, so having ability to put comments from one location would be huge plus.