Replies: 3 comments
-
Of course apart from not doing the inheritance and just documenting the emit and register functions for every subclass |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I found a way to make it work for ---@class entity.class<T>: {
--- emit: fun(self, event: T, ...),
--- register: fun(self, event: T, f: fun(...)),
---}
---@field signals table
---@alias signals.player
---|"update"
---|"before_draw"
---|"draw"
---|"after_draw"
---|"destroy"
---|"take_damage"
---|"dead"
---|"attack"
---|"running"
---|"move"
---|"idle"
---|"heal"
---|"after_attack"
---|"after_dead"
---|"after_running"
---|"look"
---@type entity.class<signals.player>
local e
e:emit() --< completion works here
---@class player.class: entity.class<signals.player>
local Player
Player:emit() --< but not working here, shows: Undefined field `emit`. updated: I found a hack ?!Alright I think I found a hack 😂
-- entity definition same as above ...
---@diagnostic disable-next-line: duplicate-doc-alias
---@alias player.class player.class|entity.class<signals.player>
---@class player.class
local Player
Player:emit() --< now the completion works !! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, i would like to ask for help
lets say i have class like this one:
now for i have class that inherits from entity.class like this one:
So yeah, the code i provided is not working.
Is there a way for this to work?
Beta Was this translation helpful? Give feedback.
All reactions