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
---@metalocalFoo= {}
---@overloadfun(a: string): string---@overloadfun(a: number): tablefunctionFoo.Bar(a)
endlocalb=Foo.Bar('abc') -- type of is `string|nil`
Additional Notes
Log File
No response
The text was updated successfully, but these errors were encountered:
I think that's because you did not define the base type of the function, so LuaLs just infer the base type by itself, that this empty function can return nil. To workaround this, you may change one of the ---@overload declaration into ---@param and ---@return:
---@metalocalFoo= {}
---@paramastring---@returnstring---@overloadfun(a: number): tablefunctionFoo.Bar(a)
endlocalb=Foo.Bar('abc') -- type of is `string` now
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Type Checking
Expected Behaviour
type of
b
should bestring
Actual Behaviour
type of
b
isstring|nil
Reproduction steps
Additional Notes
Log File
No response
The text was updated successfully, but these errors were encountered: