How to allow the injection of new fields to avoid "fields cannot be injected" error? #2356
-
How to allow the injection of a new field to a predefined class?
Is there a better way instead of redefining and casting to a new extended class like this:
How about adding a
or is there an alternative that I haven't found yet? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
carsakiller
Oct 1, 2023
Replies: 1 comment 2 replies
-
There are a few options:
---@class A
local a = {}
function a:myFunction() end
---@class A
---@field myFunction? fun(self: A, a: string): boolean
---@type A
local a = {}
function a:myFunction(a)
return true
end |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Dennis1000
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are a few options: