druid
druid copied to clipboard
Added `@generic T` to the methods that returns the passed component t…
Added the generic type T to the annotations to avoid type loss during the component instance creating.
Example of the solved problem:
-- some component
---@class pocket_view: druid.base_component
...
-- some class property
---@field pocket_view pocket_view
...
-- assigning
self.pocket_view = self.druid:new(PocketView, 'pocket')
-- Warning that the returned class druid.base_component is not the expected pocket_view
...
Thanks for contribution!
Since the annotations.lua is generated file, I will update the source code to able generate the same thing. It seems very useful!
Oh this issue get auto-closed I added the generics for the druid_instance:new function, so it should be generally okay
Will aim to replace annotations to code-annotations only and this will be much easier to set all generics we want, will wait a little bit more