Function wrapper that changes the return value #2737
Unanswered
Periapsises
asked this question in
Q&A
Replies: 2 comments 4 replies
-
|
Beta Was this translation helpful? Give feedback.
4 replies
-
In the current state of LuaLS, the workaround that I can come up with is to inline the ---@generic T
---@param func fun(): T
---@return fun(): { value: T, error: string }
local function wrap(func) end
---@return boolean
local function myFunc() end
local myFuncWrapped = wrap(myFunc)
print( myFuncWrapped().value ) -- `value` is now boolean Or you may try another plugin with better generics support as suggested by the above comment. 😃 |
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.
-
I'm trying to make a wrapper for a function that changes the return value of the function passed.
Here is an example of what I'm trying to achieve.
I don't know if I'm just doing it wrong or if it's not possible given the current state of generics.
Beta Was this translation helpful? Give feedback.
All reactions