-
-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for the ability to annotate non-defined functions like classes #2394
Comments
It'd also be useful in being able to assign detailed annotations for functions that cannot be defined as a named function - example: local t = {
[1] = {},
[2] = {},
[3] = {},
}
for i = 1, #t do
---@type specified_function_typeName
t[i].f = function() print(i) end
end |
I think this is a duplicate of #1456. The conclusion we came to is that there should be a |
It's not quite a duplicate but there is mention of an abstract/pre-defined I would actually expect warnings when the function definition does not match the pre-described annotations being applied to it - i.e. when it's implemented. Not sure if this should be closed yet, because that's not exactly what I read in the mentioned issue - but it may still very well be what you mean as well. If anything, what's described in this comment #2415 (comment) is a duplicate of this. I'm not sure why you closed & tagged it as not planned and I think there may be a misunderstanding which I'd love to clear up given the chance. Are we in fact talking about the same thing (I described above) and is what I'm suggesting not planned, or you used not planned to get rid of the multiple threads of speak about similar issues (in which case, fair enough but I'm not sure we are on the same page yet? |
That issue asks for the implementation of a #2415 was closed by its author when I pointed out the existence of #1456. This functionality has been requested by many people, so I am just trying to keep everything in one place when the solution is to add a |
Hello!
I think it'd be really useful if we could annotate
@param
and@return
descriptions for not yet defined functions named like classes and then apply that list of descriptions to the type of a@field
or to any variable through@type
. If I use virtual or abstract functions in other languages to be implemented later, I can usually add detailed annotations to them which the implementation would also inherit.The current extent of predescribing a function used as a type gets exhausted in
fun([param: type...]): [return: type...]
, which already is nice but I really miss the ability to add individual descriptions to and perhaps additional note lines under each parameter and return value.An example of how it could look like:
utilizing a possible new annotation keyword of
@function [name] [fun(...) type]
to be used as:
or:
If there already is a way to do this or a good way to achieve the same result, please let me know! I'd be very happy if I could annotate like this. Thank you in advance!
The text was updated successfully, but these errors were encountered: