lua-language-server
lua-language-server copied to clipboard
Generics, inheritance and an overloaded constructor
VisualStudio Code on Windows, lua-language-server v3.7.4 (Last updated 2024-01-07, 10:29:54)
The following error occurs only when a generic inherits from a type containing an overloaded constructor.
local e = Entity()
e:get(Transform2)
e:get(Transform)
The only difference between Transform and Transform2 is the overloaded constructor.
I could "workaround" this issue by removing : ComponentBase from the function Entity:get ... but I want to check whether the given component type is valid.
Here is the simplified annotation file:
---@class ComponentBase
---@class Transform: ComponentBase
Transform = {}
---@class Transform2: ComponentBase
---@overload fun(x: number, y: number): Transform2
Transform2 = {}
---@class Entity
---@overload fun(): Entity
Entity = {}
---@generic T: ComponentBase
---@param type T
---@return T
function Entity:get(type) end