Skip to content

Whats up with the hashtags? #3376

@ChillerDragon

Description

@ChillerDragon

I see some type annotations using # and some not. Also even the wiki https://luals.github.io/wiki/annotations/ sometimes uses it and sometimes not. Is it good style? Is it more portable?

---@alias DeviceSide
---| '"left"' # The left side of the device
---| '"right"' # The right side of the device
---| '"top"' # The top side of the device
---| '"bottom"' # The bottom side of the device
---| '"front"' # The front side of the device
---| '"back"' # The back side of the device

---@param side DeviceSide
local function checkSide(side) end

https://github.com/LuaCATS/love2d/blob/765abafe49775ba52937430e2546dfc330381d6b/library/love.lua#L10-L20

---
---Gets the current running version of LÖVE.
---
---
---[Open in Browser](https://love2d.org/wiki/love.getVersion)
---
---@return number major # The major version of LÖVE, i.e. 0 for version 0.9.1.
---@return number minor # The minor version of LÖVE, i.e. 9 for version 0.9.1.
---@return number revision # The revision version of LÖVE, i.e. 1 for version 0.9.1.
---@return string codename # The codename of the current version, i.e. 'Baby Inspector' for version 0.9.1.
function love.getVersion() end

Or here one from the wiki without hashtags in the "Simple Documentation of a Class" example

---@class Person
---@field height number The height of this person in cm
---@field weight number The weight of this person in kg
---@field firstName string The first name of this person
---@field lastName? string The last name of this person
---@field age integer The age of this person

---@param person Person
local function hire(person) end

I understand it starts the description. But I don't understand when its needed and if I should use it or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions