Replies: 1 comment
-
For the 2nd case, there is a ---@return integer result
local function test2()
return 12.3 --[[
Annotations specify that return value #1 has a type of `integer`, returning value of type `number` here instead.
- `number` cannot match `integer`
- The number `12.3` cannot be converted to an integer
]]
end For the table type checking I am not sure 😕 --- enable in your config, "type.checkTableShape": true
---@class test.ret
---@field value integer
---@return test.ret result
local function test4()
return { value = "" } --[[
Annotations specify that return value #1 has a type of `test.ret`, returning value of type `table` here instead.
- `table` cannot match `test.ret`
- `string` cannot match any subtypes in `integer`
- `string` cannot match `integer`
- Type `string` cannot match `integer`
]]
end
---@return test.ret result
local function test5()
return { wrong = "test" } --[[
Annotations specify that return value #1 has a type of `test.ret`, returning value of type `table` here instead.
- `table` cannot match `test.ret`
- Missing required fields in type `test.ret`: "`value`"
]]
end => this way will have warnings 🤔 a similar issue reported: #2802 (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
-
Hi,
I don't manage to get accurate diagnostics when enforcing return types, consider these examples:
As noted, only the string instead of integer gives a diagnostics. All others pass for me. Especially I can't make it check my table returns to validate keys and types.
Any ideas?
Cheers, Daniel.
Beta Was this translation helpful? Give feedback.
All reactions