lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Way to annotate `@overload` only table, instead of the entire `@class`

Open d-enk opened this issue 1 year ago • 2 comments

---@class Class
---@overload fun(): self|Class
local Class = {}

local c = Class()

local unknown = c() -- but unknown is Class

I thought that was the indication self/Class was responsible for this

self for object Class for table

But today I discovered that this is not so. And in previous versions as well

In principle, this can be achieved by explicitly making

---@cast Class Class|fun(): Class

But for long names it is extremely monstrous

d-enk avatar Aug 27 '24 11:08 d-enk