Insality / druid

Powerful Defold UI component framework
https://insality.github.io/druid/modules/Druid.html
MIT License
276 stars 33 forks source link

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

Open astrochili opened 9 months ago

astrochili commented 9 months ago

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
...
Insality commented 7 months ago

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!