-
-
Notifications
You must be signed in to change notification settings - Fork 402
Open
Labels
enhancementNew feature or requestNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)Related to Lua Language Server Annotations (LuaCats)feat/type checkRelated to the type checking featureRelated to the type checking feature
Description
As a simple example, I would like to annotate the following @guard x string. This is in effect returning a boolean, which narrows down the type of the argument x.
---@param x unknown
---@guard x string
local function isString(x)
return type(x) == "string"
end
---@param x string | number
local function main(x)
if isString(x) then
-- x is string
print(x)
else
-- x is number
print(x)
end
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)Related to Lua Language Server Annotations (LuaCats)feat/type checkRelated to the type checking featureRelated to the type checking feature