Open
Description
Issue Description
I noticed two examples about backticks.
The first is in @generic
Capture with Backticks
---@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
---@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?
---@return T
---@return `T`
Additional Notes
BTW, how can I annotate this:
---@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?