Skip to content

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

Open
@Nexela

Description

@Nexela

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions