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
However in the above case the local Class will be table|fun():Class only. That means in the following code:
---@classClass---@fieldcintegerlocalClass= {} ---@typefun(): ClassfunctionClass:a()
self. --< trigger auto complete here, it will not suggest `.c` field, because `self` is just `table` type not `Class`end
If you need it to be Class instead of table, you need to write:
---@classClass---@fieldcintegerlocalClass= {} ---@typeClass|fun(): ClassfunctionClass:a()
self. --< now it will suggest `.c` field hereend
---@cast Class Class|fun(): Class
But for long names it is extremely monstrous
In addition, the @cast supports [+|-]<type> syntax. So in your original method, you can write:
---@castClass+fun(): Class
So at best only 1 Class less 😅
If you really want to distinguish between a class and an instance, maybe you should create 2 classes Class and Class.instance in the first place 🤔 And only Class have the overload to return a Class.instance. That way a Class.instance will not have the function call type.
I thought that was the indication
self/Class
was responsible for thisself
for objectClass
for tableBut today I discovered that this is not so.
And in previous versions as well
In principle, this can be achieved by explicitly making
---@cast Class Class|fun(): Class
But for long names it is extremely monstrous
The text was updated successfully, but these errors were encountered: