-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot recognize emmy field #1971
Comments
You should use: ---@class equipment_mgr
local mt = {}
mt.__index = mt
---@return db.Equipment
function mt:get_equipment(uid)
return self.equipment[uid]
end |
@carsakiller It seems that many people will try to declare fields for class by |
Would it not be documented like this? I believe this is how the wiki explains it. ---@class role
---@field equipment_mgr equipment_mgr
---@class equipment_mgr
---@field role role
---@field equipment db.Equipment[]
local data = {
role = role,
equipment = orm_equipment,
}
---@type equipment_mgr
local mt = {}
mt.__index = mt
---@return db.Equipment
function mt:get_equipment(uid)
return self.equipment[uid]
end Or would we have to use |
If I declare class in this way, then how would I declare data fields in emmy class? It seems declaring fields to class annotated with @type does not work🤔 |
@sumneko I am confused 😄. Could you clarify how and why this should be done? |
incorrect ---@class A
---@type A
local m = {}
m.someValue = 1 -- can not declare field `someValue` into `A`
---@type A
local n
print(n.someValue) -- undefined-field correct ---@class A
---@class A
local m = {}
m.someValue = 1 -- declare field `someValue` into `A`
---@type A
local n
print(n.someValue) -- integer just think about this: ---@class A
local m = {}
m.count = 0
---@type A
local n
n.coount = n.coount + 1 -- don't declare `coount` into `A` |
@sumneko I have three modules, each module declares some methods to a same class, how could I add these methods into the class?
use @Class in all these files will lead to duplicate class definition. Do you have some suggestions? Thank you 😘 |
I added a note to |
I have defined an emmy class
role
:an emmy class
equipment_mgr
:then add some method to
equipment_mgr
:Lua Diagnostics cannot recognize the method
get_equipment
:while other extension can
The text was updated successfully, but these errors were encountered: