Skip to content

Incorrect type on string-key fields when combined with [string] #3365

@justarandomgeek

Description

@justarandomgeek

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

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