LuaLS / LuaLS/lua-language-server
Way to annotate `@overload` only table, instead of the entire `@class`
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
---@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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue's Lua snippet in the language server and trace how @class and @overload annotations are interpreted. Determine how an overload can apply to the class table without changing the instance type, then add coverage for the example and verify that the inferred type of unknown is Class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100