Skip to content

---@aliases don't work in v3.x as they did in v2.6.8 #1061

@C3pa

Description

@C3pa

Describe the bug
In v3.x fields defined in ---@alias with '' get converted to string literals (inside ""). That wasn't the behavior of the older versions.

To Reproduce
Steps to reproduce the behavior, use the following code:

local ngx = {}

ngx.DEBUG  = 8
ngx.INFO   = 7
ngx.NOTICE = 6
ngx.WARN   = 5
ngx.ERR    = 4
ngx.CRIT   = 3
ngx.ALERT  = 2
ngx.EMERG  = 1
ngx.STDERR = 0

--- NGINX log level constants
--- https://github.com/openresty/lua-nginx-module/#nginx-log-level-constants
---@alias ngx.log.level
---| 'ngx.DEBUG'  # debug
---| 'ngx.INFO'   # info
---| 'ngx.NOTICE' # notice
---| 'ngx.WARN'   # warning
---| 'ngx.ERR'    # error
---| 'ngx.ALERT'  # alert
---| 'ngx.CRIT'   # critical
---| 'ngx.EMERG'  # emergency
---| 'ngx.STDERR' # standard error
---@param level ngx.log.level
---@param ... string|number|'nil'|'ngx.null'
function ngx.log(level, ...) end

ngx.log
  1. Start typing (
  2. See the error

Expected behavior
The expected behavior is the behavior from v2.6.8. The alias entries enclosed in single '' shouldn't be converted to string literals (enclosed with "").

Screenshots

  • v3.0.2:

image

  • The autocomplete suggestion.

image

  • What the autocomplete expands to.

  • v2.6.8:

image

  • The autocomplete suggestion.

image

  • What the autocomplete expands to.

Environment:

  • OS: Windows
  • Client: VSCode

Additional context
If there is a reason why this is changed, could you instruct me on how to achieve the same result with a different approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions