You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, alias only takes a name along with values (using the expanded form of alias for example purposes)
---@alias areaType
---| 'TOP'
---| 'BAG
---@param area? areaType
StoreItem = function (area)
if (area:lower() == 'top') then
print('this is a top area')
end
end
The problem comes in that if I want to do anything with those values such as normal string operations (e.g., area:lower()), the editor reports that operation as an undefined field.
I can add string to the alias to eliminate this error.
---@alias areaType string
---| 'TOP'
---| 'BAG
However, string now shows up in the function signature.
I also tried adding ---@type string in front of the alias, but this wasn't recognized.
An enhancement to allow typing the alias or automatically recognizing a list of string values and bringing in the string operations accordingly would address this. I'd prefer the explicit typing as this would open the door to creating enums of other types.
The text was updated successfully, but these errors were encountered:
Currently,
alias
only takes a name along with values (using the expanded form ofalias
for example purposes)The problem comes in that if I want to do anything with those values such as normal string operations (e.g., area:lower()), the editor reports that operation as an undefined field.
I can add
string
to thealias
to eliminate this error.However,
string
now shows up in the function signature.I also tried adding
---@type string
in front of thealias
, but this wasn't recognized.An enhancement to allow typing the alias or automatically recognizing a list of string values and bringing in the string operations accordingly would address this. I'd prefer the explicit typing as this would open the door to creating enums of other types.
The text was updated successfully, but these errors were encountered: