Skip to content

rawset does not support ---@class annotations #2862

@LJSonik

Description

@LJSonik

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Expected Behaviour

I expect EntitySerializer.serializePlayer to autocomplete properly in main.lua.

Actual Behaviour

It does not autocomplete because the ---@class annotation is apparently ignored with rawset.
It works if I do EntitySerializer = {} instead, but I cannot do that in the environment I work with.

Reproduction steps

EntitySerializer.lua:

---@class EntitySerializer
rawset(_G, "EntitySerializer", {})

Player.lua:

---@class EntitySerializer
local m = EntitySerializer

function m.serializePlayer(player)
end

main.lua:

EntitySerializer. -- No autocompletion here

Additional Notes

No response

Log File

No response

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