druid icon indicating copy to clipboard operation
druid copied to clipboard

Added `@generic T` to the methods that returns the passed component t…

Open astrochili opened this issue 2 years ago • 1 comments

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
...

astrochili avatar Dec 12 '23 16:12 astrochili

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!

Insality avatar Jan 26 '24 12:01 Insality

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

Insality avatar Oct 19 '24 09:10 Insality