luttje / luttje/glua-api-snippets

Global tables (like DVScrollBar, GM and BaseClass) aren't exposed globally

Open
#50 6 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
45
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I'm not sure what exactly is going on here but the glua definitions for panels are doing some weird things resulting in functions going missing.

Snippet from `sumneko.lua\addonManager\addons\garrysmod\module\library\dvscrollbar.lua` updated fresh from the addon manager:
```lua
---@meta

---[CLIENT AND MENU] Sets the scroll level in pixels.
---
---[(View on wiki)](https://wiki.facepunch.com/gmod/DVScrollBar:SetScroll)
---@param scroll number The new scroll value.
function DVScrollBar:SetScroll(scroll) end

---[CLIENT AND MENU] Returns the amount of scroll level from the top in pixels
---
---[(View on wiki)](https://wiki.facepunch.com/gmod/DVScrollBar:GetScroll)
---@return number # The amount of scroll level from the top
function DVScrollBar:GetScroll() end

---@class DVScrollBar : Panel
local DVScrollBar = {}
```

Those two functions are placed above the class annotation and are throwing undefined-field diagnostic errors as a result.

As a separate but related issue, global tables like `DVScrollBar`, `GM` and `BaseClass` are defined as locals in the snippet files, requiring people to manually add them to `diagnostics.globals` which seems unnecessary.

Contributor guide

Open the contributing guide

Research direction

Start with the generated addon file at sumneko.lua\addonManager\addons\garrysmod\module\library\dvscrollbar.lua and inspect how declarations are ordered and scoped around the DVScrollBar class. Trace the generator or scraper entry point that produces this file. Done means the methods no longer trigger undefined-field diagnostics and globals such as DVScrollBar, GM, and BaseClass do not require manual diagnostics.globals entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.