LuaLS / LuaLS/lua-language-server
Be confused to Backticks
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
### Issue Description
I noticed two examples about backticks.
The first is in `@generic` Capture with Backticks
```lua
---@class Vehicle
local Vehicle = {}
function Vehicle:drive() end
---@generic T
---@param class `T` # the type is captured using `T`
---@return T # generic type is returned
local function new(class) end
-- obj: Vehicle
local obj = new("Vehicle")
```
The second is in `@param` Generic Function Parameter
```lua
---@class Box
---@generic T
---@param objectID integer The ID of the object to set the type of
---@param type `T` The type of object to set
---@return `T` object The object as a Lua object
local function setObjectType(objectID, type) end
--> boxObject: Box
local boxObject = setObjectType(1, "Box")
```
Are there any differences between them?
```lua
---@return T
---@return `T`
```
### Additional Notes
BTW, how can I annotate this:
```lua
---@class X
---@field A integer
---@field B string
---@field C boolean[]
---@param x X
---@param key string
---@return ?
function getter(x, key)
return x[key]
end
```
Is it possible to use backticks?
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
The issue names no repository files, tests, or entry points. Start by comparing the two documented backtick examples and the getter annotation, then determine whether the documentation clearly defines their meanings and the expected annotation for dynamic field access; done means the differences and supported syntax are documented or the issue is resolved with a specific documentation change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100