lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Enhancement ---@fieldread, ---@fieldwrite or attribute modifiers on typing

Open Nexela opened this issue 3 years ago • 1 comments

When using some c api's (In my case Factorio's modding api) when you retrieve a value you get one type, but you can set it with multiple different types.

---@class Surface
---@class Player
local Player = {}
---@fieldread surface Surface
---@fieldwrite surface Surface|string

local p = Player.surface --- p is Surface
p.surface = "Other Surface" --No warnings

Another thought I had was attribute types, which would more easily support more attributes in the future

---@field{read} surface Surface
---@field{write} surface Surface|string
---@field{read,write} surface -- the default if no attributes are supplied

Nexela avatar Jul 08 '22 03:07 Nexela