LuaLS / LuaLS/lua-language-server
Incorrect type on string-key fields when combined with `[string]`
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
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?
Type Checking
Expected Behaviour
we have a (generated) class like
---@class GlobalModSettings
---@field ["heat-visualizer-updates-per-surface-per-tick"] ModSetting<int32>
---@field ["nixie-tube-update-speed-alpha"] ModSetting<int32>
---@field ["nixie-tube-update-speed-numeric"] ModSetting<int32>
---@field [string] ModSetting<(int32)|(double)|(boolean)|(string)|(Color)>
which has narrower types for the known entries and a general type for the "everything else" field, but when i then use this type like
local x = settings.global["heat-visualizer-updates-per-surface-per-tick"]
x is given the type from the [string] field, rather than the one that is an exact match for that specific string
Actual Behaviour
(this template is always off screen and i've written the whole thing in the first box...)
Reproduction steps
(this template is always off screen and i've written the whole thing in the first box...)
Additional Notes
No response
Log File
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定仓库文件或测试名称。首先通过 Visual Studio Code extension,在 Lua language server 中复现带注解的 GlobalModSettings 查找,然后跟踪索引字段的类型解析。完成的标准是,精确字符串键字段获得其更窄的类型,而不是更宽泛的 [string] 字段类型。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100