Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using ---@class on rawset(_G, ...) to annotate the created global variable #2867

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

tomlau10
Copy link
Contributor

closes #2862 (feature request), fixes #2863


This adds supports for using ---@class on rawset(_G, "key", {}) to specify the type of the created global variable:

---@class Test
rawset(_G, "Test", {})
print(Test) -- type: `Test`, instead of just `table`

Implementation details: #2862 (comment)
While implementing this, a bug related to rawset() was discovered and fixed as well: #2863 (comment)

@sumneko sumneko merged commit 6ba0c93 into LuaLS:master Sep 25, 2024
11 checks passed
@sumneko
Copy link
Collaborator

sumneko commented Sep 25, 2024

Thank you!

@tomlau10 tomlau10 deleted the feat/rawset_with_class branch September 25, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Globals set with rawset are always parsed as a table rawset does not support ---@class annotations
2 participants