Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event emitter support fix #1011

Merged
merged 4 commits into from
Apr 2, 2022
Merged

Conversation

Cassolette
Copy link
Contributor

@Cassolette Cassolette commented Apr 2, 2022

After the fix for #809 landed, Luadoc functions needed to specify the self argument if it were meant to be used as an OOP method.

This PR updates the event emitter spec to support self and fixes a few crashes / completion issues, such as:

--- @class EmitFail
--- @field on fun(self, eventName: string, cb: function)
--- @field on fun(self, eventName: '"died"', cb: fun(i: integer))
--- @field on fun(self, eventName: '"won"', cb: fun(s: string))
local emit = {}
emit:on("died", --[[ completion here crashes ]])
emit.on("died", --[[ completion here crashes ]])

Before, wrong position for completion:
image

After fix:
image

(Edit) I am not familiar with the code architecture, do let me know if there should be any changes !

@sumneko
Copy link
Collaborator

sumneko commented Apr 2, 2022

It's a great work, thank you!

@sumneko sumneko merged commit db2771b into LuaLS:master Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants