You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---@param event_name string @Name of the event to subscribe to
---@param callback function @Function to call when the event is triggered
---@return function @The callback function passed${subOverloads}
function ${cls.name}${cls.staticClass ? "." : ":"}Subscribe(event_name, callback) end
---Unsubscribe from an event
---@param event_name string @Name of the event to unsubscribe from
---@param callback? function @Optional callback to unsubscribe (if no callback is passed then all callbacks in this Package will be unsubscribed from this event)${unsubOverloads}
function ${cls.name}${cls.staticClass ? "." : ":"}Unsubscribe(event_name, callback) end`;
When adding the Subscribe/Unsubscribe functions to the annotations it should always be static. If you leave it with : it will give an error in the game but not in the IDE. So to fix it I think that lines 231-246 should be changed to this:
subOverloads+=`\n---@overload fun(event_name: "${event.name}", callback: ${callbackSig}): ${callbackSig}${generateInlineDocstring(event)}`;unsubOverloads+=`\n---@overload fun(event_name: "${event.name}", callback: ${callbackSig}) ${generateInlineDocstring(event)}`;});events=`---Subscribe to an event---@param event_name string @Name of the event to subscribe to---@param callback function @Function to call when the event is triggered---@return function @The callback function passed${subOverloads}function ${cls.name}.Subscribe(event_name, callback) end---Unsubscribe from an event---@param event_name string @Name of the event to unsubscribe from---@param callback? function @Optional callback to unsubscribe (if no callback is passed then all callbacks in this Package will be unsubscribed from this event)${unsubOverloads}function ${cls.name}.Unsubscribe(event_name, callback) end`;
The text was updated successfully, but these errors were encountered:
If both static and non-static overloads are provided, then it wont correctly select between overloads taking self depending on the first param.
The way I get around this is by only defining static or non-static subscribes depending on the class, despite most classes implementing both.
The only alternative is breaking autocomplete until the above is fixed.
Also the annotations shouldn’t always be static, most classes implement both a static and non-static version
nanosworld-vscode/src/index.ts
Lines 231 to 246 in 0d4caa0
When adding the Subscribe/Unsubscribe functions to the annotations it should always be static. If you leave it with : it will give an error in the game but not in the IDE. So to fix it I think that lines 231-246 should be changed to this:
The text was updated successfully, but these errors were encountered: