Lua warning with render.constant_buffer

These two lines of code

local constants = render.constant_buffer()
constants.tint = self.back_tint

gives me the following warning in VSCode:

Fields cannot be injected into the reference of userdata for tint. To do so, use @class for constants.

Is there a way to fix this warning? I don’t understand the suggestion…

Thanks!

i don’t use vscode but try putting --@class table or --@type table at the top and check if fixes the warning.

I am sorry, but I still don’t understand how should I change those two lines… Could you please write them down for me here? Thank you sooo much!

--@type table
local constants = render.constant_buffer()
constants.tint = self.back_tint

Thanks, now I understand what you mean! But unfortunately nothing changes…

try it with three dashes then ---@type table

---@type table
local constants = render.constant_buffer()

gives the following error on constants:

Cannot assign `userdata` to `table`.
- `userdata` cannot match `table`
- Type `userdata` cannot match `table`Lua Diagnostics.(assign-type-mismatch)

I really appreciate your help! Thanks!

hm ok, then you are out of luck i guess, you can’t type check userdata in lua.
Unfortunately, this means you’ll have to live with this warning.

No problem in living with this. But then why vscode is complaining? I don’t understand!

Anyway, thanks again!