Replies: 1 comment 1 reply
-
Back to the question, I don't quite understand what you are going to achieve. 😕
I don't think LuaLS is designed to enforce the implementation of a given module. ---@class MyModule
local M = {}
function M.do_thing() return "hello, world" end
And if you really want to use it to enforce the module implementation, the only suggestion that I can think of is to inline the function declaration, so that you don't need to repeat ---@type MyModule
local M = {
do_thing = function ()
return "hello, world"
end,
}
return M Maybe other experts of LuaLS can help achieve your goal using better ways 🙂 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For instance, if I had a class that a few different modules returned:
And I wanted to declare the table at the top:
I get the following error at the definition of
M
:So, is there a way to annotate the return instead of the object itself?
I have tried all of these methods, but they don't seem to actually enforce that the
do_thing
field is present:P.S. I know I could do this
But... I think it's ugly, and
do_thing
is repeated 3 timesBeta Was this translation helpful? Give feedback.
All reactions