lua-language-server
lua-language-server copied to clipboard
Annotations with mixins?
Hi I'm trying to make annotations that must require the user to have certain fields in a table as a requirement.
For instance, I want a table that needs to have x,y fields, or certain functions.
Here is some pseudo-code that might explain what I mean:
---@class Spinnable
---@field spin fun()
---@class Positionable
---@field x number
---@field y number
---@field setPos fun(x: number, y: number)
---@generic T : Spinnable, Positionable
---@param p1 `T`
---@return T
local function doFunction(p1) return p1 end
local entity = { x = 5 } -- A table that is missing the other fields
local check = doFunction(entity) -- I want a warning here saying it doesn't have, `y`, `setPos()`, or `spin()`
Is this currently possible to require certain fields in a table?
This would be a really great addition! Currently the only issue im running into.