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
I am struggling to correctly define/annotate a callback function - I've searched the web (and here), but I did not find any way to define a function including its parameter annotations, then use this as part of another functions parameter.
Here is what is working:
---@aliasCallbackFunctionTypefun(p1 : string, p2 : string) : string---Register a callback function---@paramcallbackCallbackFunctionType Function to be registeredfunctionRegisterCallback(callback) end
However, this does not provide full parameter information (i.e. the individual parameter descriptions) when doing code completion or code hints for the RegisterCallback function. So I was trying to define the function normally, then use it as a type:
---This function is called whenever the condition is met, register it through RegisterCallback()---@paramp1string first parameter---@paramp2string second parameter---@returnstring result Result stringfunctionCallbackFunction(p1, p2)
end---Register a callback function---@paramcallbackCallbackFunction Function to be registeredfunctionRegisterCallback(callback) end
This is (obviously) not working, as CallbackFunction is not a type - so it can't be used in the parameter list of the RegisterCallback function. But this describes the use case I have...
Here is what I can see in VSCode for the above try:
Any hint on how function parameters with full annotations can be defined would be highly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am struggling to correctly define/annotate a callback function - I've searched the web (and here), but I did not find any way to define a function including its parameter annotations, then use this as part of another functions parameter.
Here is what is working:
However, this does not provide full parameter information (i.e. the individual parameter descriptions) when doing code completion or code hints for the
RegisterCallbackfunction. So I was trying to define the function normally, then use it as a type:This is (obviously) not working, as
CallbackFunctionis not a type - so it can't be used in the parameter list of theRegisterCallbackfunction. But this describes the use case I have...Here is what I can see in VSCode for the above try:

Any hint on how function parameters with full annotations can be defined would be highly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions