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
Love the new exact class! When using it though, I noticed that I could still 'inject' fields into an exact class when it is used as the input to a function. Example:
---@class (exact) TestClass
---@field public a number
---@field public b string
---@field public c boolean
---@param test_param TestClass
local function test(test_param)
end
test({a = 1, b = "2", c = true, d = 4})
causes no error.
I am not sure if this is intended or not, but I would expect to get an warning like: Fields cannot be injected into the reference of `TestClass` for `d`. To do so, use `---@class` for `test_param`.Lua Diagnostics.(inject-field) here.
The text was updated successfully, but these errors were encountered:
GiuseppeIII
changed the title
Can add a param to an exact class that is used as the input to a function
Exact classes can have fields injected when used as parameters to funcitons
Aug 25, 2023
Love the new exact class! When using it though, I noticed that I could still 'inject' fields into an exact class when it is used as the input to a function. Example:
causes no error.
I am not sure if this is intended or not, but I would expect to get an warning like:
Fields cannot be injected into the reference of `TestClass` for `d`. To do so, use `---@class` for `test_param`.Lua Diagnostics.(inject-field)
here.The text was updated successfully, but these errors were encountered: