VSCode-EmmyLua icon indicating copy to clipboard operation
VSCode-EmmyLua copied to clipboard

Bad support for OOP libraries :(

Open winterwolf opened this issue 5 years ago • 0 comments

Please, look at this short example:

local class = require "middleclass" ---@type MiddleClass

local Fruit = class("Fruit")

---@param color table
---@param size number
function Fruit:initialize(color, size)
  self.color = color --- Color comment.
  self.size = size --- Size comment.
end

I use MiddleClass library for OOP, but problem not exactly in this library, this is common issue.

Look, the good thing here is that we can describe class fields in constructor, so we no need to copy them in class descriptions. This is very nice.

But the bad thing and my actual issue is that when we create a new instance of class, like Fruit({1,0,0}, 1) we don't get any hints about accepted arguments between brackets and I have no idea how to provide them.

I think, the best solution here is provide some describer for synonyms/shortcuts, like this:

---@shortcut class.new
---@shortcut class
function class:initialize(...)
end

winterwolf avatar Nov 08 '20 14:11 winterwolf